Set x-axis interval

27 次查看(过去 30 天)
ImpactMike
ImpactMike 2020-6-10
Hi,
I'm just a bit confused about how to set the interval on my x-axis, to ensure that my graph is plotted in increments of 1 instead of decimals.
I have reviewed other posts but my situation is slightly different because I have multiple graphs to plot, using a control loop. So I would like every graph to have an interval of 1 on the x-axis.
Saw this on a related post and tried it but it didn't work --> set(gca,'XTick',(INTERVAL)).
Please help.
Thank you

采纳的回答

Ameer Hamza
Ameer Hamza 2020-6-10
编辑:Ameer Hamza 2020-6-10
You can use xticks function in R2016b and later
current_ticks = xticks;
xticks(round(min(current_ticks)):1:round(max(current_ticks)));
earlier releases
current_ticks = get(gca, 'XTick');
set(gca, 'XTick', round(min(current_ticks)):1:round(max(current_ticks)));
  2 个评论
ImpactMike
ImpactMike 2020-6-11
Thank you so much for this Ameer! Much appreciated x
Ameer Hamza
Ameer Hamza 2020-6-12
I am glad to be of help!

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by