How to change the x axis labels of a plot so that they only show integer values
229 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/248425/image.png)
Thanks!
3 comentarios
Respuestas (2)
Walter Roberson
el 15 de Nov. de 2019
ax = gca;
ax.Xticks = unique( round(ax.XTicks) );
2 comentarios
Walter Roberson
el 12 de Mzo. de 2020
Editada: Walter Roberson
el 12 de Mzo. de 2020
ax is a variable assigned the result of gca . gca is a function that returns a handle to the current axes. So ax will be assigned a handle to the current axes.
ax = gca;
ax.XTick = unique( round(ax.XTick) );
SHC
el 12 de Mzo. de 2020
curtick = get(gca, 'xTick');
xticks(unique(round(curtick)));
2 comentarios
Walter Roberson
el 12 de Mzo. de 2020
Note: this requires R2016b or later. For earlier releases, especially before R2015b, it would look like,
curtick = get(gca, 'XTick');
set(gca, 'XTick', unique(round(curtick)))
Ver también
Categorías
Más información sobre Axis Labels en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!