XData and YData from area chart

6 ビュー (過去 30 日間)
Chad Greene
Chad Greene 2021 年 11 月 2 日
コメント済み: Star Strider 2021 年 11 月 2 日
I'm using the area function to create a stacked area chart of hundreds of time series. After plotting my data via
h = area(t,Y);
I'd like to access the coordinates of all of the filled areas using
h(1).XData
h(1).YData
however, I'm surprised to find that h.XData and h.YData return the input data I gave it (time,Y) rather than the coordinates of the plotted objects.
Is there a way to access the plotted coordinates of the filled objects?

採用された回答

Star Strider
Star Strider 2021 年 11 月 2 日
Add (cumsum) ‘Y’ row-wise to get the coordinates —
t = 1:10;
Y = randi(9, 10, 3)
Y = 10×3
1 7 5 8 8 8 3 4 2 2 1 6 6 2 7 2 1 2 3 4 7 7 5 2 5 7 5 2 4 8
Ycoordinates = cumsum(Y,2)
Ycoordinates = 10×3
1 8 13 8 16 24 3 7 9 2 3 9 6 8 15 2 3 5 3 7 14 7 12 14 5 12 17 2 6 14
figure
h = area(t,Y);
grid
.
  2 件のコメント
Chad Greene
Chad Greene 2021 年 11 月 2 日
Yes, of course! Thanks Star Strider for the elegant and well-explained solution!
Star Strider
Star Strider 2021 年 11 月 2 日
As always, my pleasure!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by