Why does changing XTickLabel change the overall range of the graph axes?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 30 Apr 2020
Risposto: MathWorks Support Team
il 18 Mag 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.
Risposta accettata
MathWorks Support Team
il 30 Apr 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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!