Set x-axis interval
23 views (last 30 days)
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)).
Ameer Hamza on 10 Jun 2020
Edited: Ameer Hamza on 10 Jun 2020
You can use xticks function in R2016b and later
current_ticks = xticks;
current_ticks = get(gca, 'XTick');
set(gca, 'XTick', round(min(current_ticks)):1:round(max(current_ticks)));