Why does changing XTickLabel change the overall range of the graph axes?

조회 수: 2 (최근 30일)
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
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개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by