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!
