XData and YData from area chart

9 次查看(过去 30 天)
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!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by