X axis is not displaying final value
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Louise Wilson
le 20 Août 2019
Réponse apportée : melanie basnak
le 30 Août 2019
I am trying to plot my x-axis from min(x) to max(x) but for some reason the final value wont display, even though the plot runs to the final value.
The values run from 0-115 and I am looking to display 115 on the x-axis, how can I do this?
Thanks!
figure;
colormap(jet); %changes colour scheme
caxis([-80 -45]); % sets scale on colour bar
axis tight;
view(0,90); %flip plot so it becomes 2D
ylim ([0 20000]);
set(gca,'tickdir','out','fontname',... %change size of axes
'arial','fontsize',14);
xlim([0, t(end)]); %change range of x axis
xticks(0:15:115); %x axis labels in intervals of 15

0 commentaires
Réponse acceptée
melanie basnak
le 30 Août 2019
It is because when you do xticks(0:15:115) you never get to 115 (i.e., if you start from 0 and ascend 15 at a time, the last number you get is 105, 15 more than that would be 120 and out of your range). You could fix this by either changing it to xticks(0:5:115), which will give you a lot of value, and include 115, or you could choose a specific subset of values, for example
xticks([0 30 60 90 115]);
xticklabels({'0','30','60','90','115'});
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 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!