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];

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 13 Oct 2020
Modifié(e) : Ameer Hamza le 13 Oct 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 commentaires

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 le 13 Oct 2020
Yes, but you need to describe which one to select? Or do you want them to be selected randomly?
I would like to display all the values that appear once along the x-axis.
Ameer Hamza
Ameer Hamza le 13 Oct 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?
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)
Nope, it was just an example. I am dealing with vectors much bigger than these.
Ameer Hamza
Ameer Hamza le 13 Oct 2020
But the same method will apply there.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by