Hello everybody,
I haven't figured out yet how can I plot discrete values along the x-axis. I need to plot for instance:
y= [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
Editada: Ameer Hamza el 13 de Oct. de 2020
Try this
y = [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];
ax = axes();
plot(y, 'r+', 'MarkerSize', 10, 'LineWidth', 2)
ax.XTickLabel = string(x);

8 comentarios

DAVIDE DELLA VALLE
DAVIDE DELLA VALLE el 13 de Oct. de 2020
Thank you so much Ameer.
Just one other thing: let's assume that I have 10000 points along the x-axis, and most of them are "89". Is it possible to display just a small amount of such a digit instead of displaying all of them?
Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
Yes, but you need to describe which one to select? Or do you want them to be selected randomly?
DAVIDE DELLA VALLE
DAVIDE DELLA VALLE el 13 de Oct. de 2020
I would like to display all the values that appear once along the x-axis.
Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
So you want to display just one point for all repeating values. For example, just one "89" on x-axis? What about y-value?
DAVIDE DELLA VALLE
DAVIDE DELLA VALLE el 13 de Oct. de 2020
yes, i do.
As far as the y-values are concerned, i would like to display all of them
Run the following code. Is this what you want?
y = [10 1 2 3 20 22 20 10 14 12];
x = [89 89 89 89 89 89 89 90 91 10];
plot(x, y, 'r+', 'LineWidth', 2, 'MarkerSize', 10)
DAVIDE DELLA VALLE
DAVIDE DELLA VALLE el 13 de Oct. de 2020
Nope, it was just an example. I am dealing with vectors much bigger than these.
Ameer Hamza
Ameer Hamza el 13 de Oct. de 2020
But the same method will apply there.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Oct. de 2020

Comentada:

el 13 de Oct. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by