Why does changing XTickLabel change the overall range of the graph axes?
2 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2020-4-30
回答: MathWorks Support Team
2020-5-18
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.
采纳的回答
MathWorks Support Team
2020-4-30
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!