Change yticks using a stacked plot
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (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 comentarios
Clay Swackhamer
el 19 de Nov. de 2020
Eric Roden
el 12 de Mzo. de 2021
Yes, thank you, it took me a long time to find this, and am very happy I did!
Bradley Stiritz
el 25 de Jun. de 2025
Thank you Adam!
Categorías
Más información sobre Axes Appearance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
