Set x-axis interval

45 visualizaciones (últimos 30 días)
ImpactMike
ImpactMike el 10 de Jun. de 2020
Comentada: Ameer Hamza el 12 de Jun. de 2020
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

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 10 de Jun. de 2020
Editada: Ameer Hamza el 10 de Jun. de 2020
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 comentarios
ImpactMike
ImpactMike el 11 de Jun. de 2020
Thank you so much for this Ameer! Much appreciated x
Ameer Hamza
Ameer Hamza el 12 de Jun. de 2020
I am glad to be of help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by