XData and YData from area chart

조회 수: 9 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by