Change yticks using a stacked plot
古いコメントを表示
Hello,
I am using the stackedplot function to display multiple series of data that share the same x axis. I would like to change the y ticks, but I can't figure out how to do it. In this case, I would like to make the y tick marks go by 4,000. So basically the y axis should have the following tick marks: 0, 4000, 8000, 12000. Attached is the figure. I can't seem to find a tick mark property in this graph and using
yticks(0:4000:12000)
returns the following error:

Using xticks with stackedplot is not supported.
Thanks,
Clay
採用された回答
その他の回答 (1 件)
You can get the axis handles in stackedplot using the undocumented NodeChildren property. Then set YTick.
rng('default')
h = stackedplot(1:20, rand(20,4)*1000+500);
ax = findobj(h.NodeChildren, 'Type','Axes');
set(ax, 'YTick', [600:300:1500], 'YLim', [500,1600])
To set ytick of a selected axis number n,
% set(ax(n), ...)
3 件のコメント
Clay Swackhamer
2020 年 11 月 19 日
Eric Roden
2021 年 3 月 12 日
Yes, thank you, it took me a long time to find this, and am very happy I did!
Bradley Stiritz
2025 年 6 月 25 日
Thank you Adam!
カテゴリ
ヘルプ センター および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
