I have a plot that has a yaxis range from 0 to 9.
I only want the yticklabels for 1 to 8 to be visible.
I have tried:
yticks = get(gca,'YTick');
ytickLabels = get(gca,'YTickLabel');
set(gca,'YTick',yticks(1:1:8), 'YTickLabel',ytickLabels(1:1:8));
But this doesnt work. How do I not show the 0 and the 9 on the ytick labels? Thanks

 채택된 답변

Star Strider
Star Strider 2015년 1월 6일

0 개 추천

Change the set call to:
set(gca,'YTick',1:1:8, 'YTickLabel',1:1:8);

댓글 수: 2

Thankyou, I alos just worked out that this works too:
set(gca,'YTick',yticks(2:1:9), 'YTickLabel',ytickLabels(2:1:9));
Star Strider
Star Strider 2015년 1월 6일
My pleasure!
Yes. You can set the 'YTickLabel' vector to whatever you want, including strings (using a cell array). The only restriction is that you have to set the positions of the 'YTick' values, and there have to be equal numbers of 'YTick' and 'YTickLabel' entries.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Ilham Hardy
Ilham Hardy 2015년 1월 6일
편집: Ilham Hardy 2015년 1월 6일

0 개 추천

Perhaps,
set(gca,'YLim',[1,8]);

댓글 수: 1

Jason
Jason 2015년 1월 6일
But then I dont see the 0 and 9 grid line, I need to see these.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

질문:

2015년 1월 6일

댓글:

2015년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by