remove certain yticklabels from axis
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
Star Strider
2015 年 1 月 6 日
Change the set call to:
set(gca,'YTick',1:1:8, 'YTickLabel',1:1:8);
2 件のコメント
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!