How to add constant line y(50) to all plots of stackedplot?

19 ビュー (過去 30 日間)
Wolfgang McCormack
Wolfgang McCormack 2021 年 5 月 21 日
回答済み: Adam Danz 2021 年 5 月 21 日
Hi all,
I am using stackedplot with 15 columns in a time table. How can I add a constant line of y(50) to all those 15 graphs in the stacked plot?
Thanks

採用された回答

Adam Danz
Adam Danz 2021 年 5 月 21 日
You can get the axis handles in stackedplot using the undocumented NodeChildren property. Then add the constant line object to each y-axis. Since yline only accepts one axis handle you can do it in a loop or use arrayfun as I have, below.
rng('default')
h = stackedplot(rand(100,5).*10+45);
ax = findobj(h.NodeChildren, 'Type','Axes');
arrayfun(@(axh)yline(axh,50,'m-','LineWidth',1),ax);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by