Issue with axis tick labels
이전 댓글 표시
Hi,
I'm trying to control the axis tick label. I'm looking at this solution on the mathworks website: http://www.mathworks.com/support/solutions/en/data/1-15HXQ/
At the very end this code is given:
plot(0:4,0:4)
set(gca,'XLim',[0 4])
set(gca,'XTick',[0:0.5:4])
set(gca,'XTickLabel',['0';' ';'1';' ';'2';' ';'3';' ';'4'])
However, I want to change the tick label to be in increments of 10. So I use:
set(gca,'XTickLabel',['0';' ';'10';' ';'20';' ';'30';' ';'40'])
and I get the following error:
"??? Error using ==> vertcat
CAT arguments dimensions are not consistent."
Any help would be appreciated. Thanks!
채택된 답변
추가 답변 (2개)
dpb
2013년 7월 30일
set(gca,'XTickLabel',['0';' ';'10';' ';'20';' ';'30';' ';'40'])
The '0' and the ' ' aren't same length as the '10', etc.
Use char instead...
set(gca,'XTickLabel',char('0',' ','10',' ','20',' ','30',' ','40'))
It's a bad example that uses only 1-character labels that leads to such errors because it's only natural for users to presume the same thing will work in general. Suggest a documentation enhancement report would not be remiss.
Jan
2013년 7월 30일
You can use the bar as separator also:
set(gca,'XTickLabel', '0| |10| |20| |30| |40')
In ancient Matlab version this has even been faster, but the modern Java GUI methods convert this internally to something like a cell string at first. But the timings will not really matter here.
카테고리
도움말 센터 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!