Replace only values in y axis
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Chiara Gigoli
le 25 Juin 2022
Réponse apportée : the cyclist
le 25 Juin 2022
Hi everyone,
I want to replace only the value on y axis of figure, without changing the plot.
I saw that I can use: yticks and ytickslabel, but they change the axis only with a text.
If I want to replace it with, for example, some elements of an array, how can I call them on the label of the axis?
Thank you in advance for the help
Chiara
0 commentaires
Réponse acceptée
the cyclist
le 25 Juin 2022
Does this do what you mean?
rng("default")
% Data to plot
x = 1:10;
y = rand(1,10);
% 11 arbitrary numeric labels for y-axis
yTickLabelArray = primes(31);
% Make plot
plot(x,y,'.-')
set(gca,"YTick",0:0.1:1,"YTickLabel",yTickLabelArray) % <---- Automatically gets converted to text for label
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
