Change yticks using a stacked plot
Show older comments
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
Accepted Answer
More Answers (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 Comments
Clay Swackhamer
on 19 Nov 2020
Eric Roden
on 12 Mar 2021
Yes, thank you, it took me a long time to find this, and am very happy I did!
Bradley Stiritz
on 25 Jun 2025
Thank you Adam!
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!