Why does changing XTickLabel change the overall range of the graph axes?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 30 de Abr. de 2020
Respondida: MathWorks Support Team
el 18 de Mayo de 2020
I create a figure and set the 'XTickLabel' property of the axis to be a certain range. When I set the range to [1:1:20], the axis only shows a range of [1:5]. When I change the range to [1:4:20], the axis now shows the proper range of [1:20] with intervals of 4. I want the range to be [1:20] with smaller intervals.
Respuesta aceptada
MathWorks Support Team
el 30 de Abr. de 2020
When you set the 'XTickLabel' property, you are setting the text that's associated with the ticks, rather than the values of the ticks.
Consider:
figure(1);clf
bar3(rand(20,30));
set(gca,'XTickLabel',0:20)
get(gca,'XTick')
figure(2);clf
bar3(rand(20,30));
set(gca,'XTickLabel',0:4:20)
get(gca,'XTick')
The values of the ticks are the same in both cases. The 'XTickLabel' only controls the text that appears in the labels (the numbers in 'xAxis' are cast to cell arrays of character vectors).
To set the ticks to be 0:20 or 0:4:20, just set the 'XTick' property. Alternatively use the 'xticks' command.
For more information about controlling various aspects of tick position, label, formatting and rotation, please refer to the link below:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Grid Lines, Tick Values, and 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!