How to change the x axis labels of a plot so that they only show integer values
조회 수: 228 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/248425/image.png)
Thanks!
댓글 수: 3
답변 (2개)
Walter Roberson
2019년 11월 15일
ax = gca;
ax.Xticks = unique( round(ax.XTicks) );
댓글 수: 2
Walter Roberson
2020년 3월 12일
편집: Walter Roberson
2020년 3월 12일
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
2020년 3월 12일
curtick = get(gca, 'xTick');
xticks(unique(round(curtick)));
댓글 수: 2
Walter Roberson
2020년 3월 12일
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)))
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!