X axis is not displaying final value

24 次查看(过去 30 天)
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
untitled.jpg

采纳的回答

melanie basnak
melanie basnak 2019-8-30
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 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by