How do I format tick labels before R2016b?
이전 댓글 표시
I have an axis with tick labels and I want them all to have 3.1 format. For example, I do a plot (1:5) and I change my tick labels using the command
set(gca, 'XTick', [1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0])
However, they appear as:
[1 1.5 2 2.5 3 3.5 4 4.5 5]
I would like to get them to appear as I typed them in the above command.
Also, I want to know if it is possible to specify the format of the plot axes tick label which is automatically placed by MATLAB.
채택된 답변
추가 답변 (2개)
Walter Roberson
2015년 9월 20일
x=[1 1.53 4];
y=[1 2 3];
plot(x,y)
set(gca,'XTick',x)
set(gca,'XTickLabel', cellstr(num2str(x(:), '%3.4f')))
set(gca,'YTick',y)
set(gca,'YTickLabel', cellstr(num2str(y(:), '%+1.2f')) )
Sergio Yanez-Pagans
2021년 8월 21일
0 개 추천
Maybe this could be useful:
https://www.mathworks.com/matlabcentral/fileexchange/97964-linemarks
카테고리
도움말 센터 및 File Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!