Change x-axis labels of plot
21 次查看(过去 30 天)
显示 更早的评论
Hi everbody,
I have a plot of 31 data points. However, instead of labeling the x-axis is (1:1:31), I want to set it to (-6:1:24). How can I do that?
Best
0 个评论
采纳的回答
Joseph Cheng
2015-5-21
solved much simpler by going
figure,plot(-6:24,1:31)
because you're setting the x and y plot pairs.
0 个评论
更多回答(3 个)
the cyclist
2015-5-21
编辑:the cyclist
2015-5-21
set(gca,'XTick',-6:24,'XTickLabel',-6:24);
Note that that command is doing two things in one line. It defining tick mark positions, and also relabeling them.
2 个评论
the cyclist
2015-5-21
编辑:the cyclist
2015-5-22
figure
plot(1:1:31);
set(gca,'XLim',[-6 24],'XTick',-6:24,'XTickLabel',-6:24);
This fixes my solution, but I think the other answers here are actually what you wanted, aligning your 31 data points with the x-axis points -6:24.
Nazmi Rosly
2021-8-13
Hi. im displaying my data from serial monitor arduino for temperature monitoring. So now it show the temperature vs second on the graph. Is there any command to change the seconds to current time like maybe 12.45 instead of its displaying 200 second.
1 个评论
the cyclist
2021-8-13
You have posted this question as an "answer" on a 6-year-old question that is unrelated. Instead, you should post a new question.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!