XData and YData from area chart

5 visualizaciones (últimos 30 días)
Chad Greene
Chad Greene el 2 de Nov. de 2021
Comentada: Star Strider el 2 de Nov. de 2021
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?

Respuesta aceptada

Star Strider
Star Strider el 2 de Nov. de 2021
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 comentarios
Chad Greene
Chad Greene el 2 de Nov. de 2021
Yes, of course! Thanks Star Strider for the elegant and well-explained solution!
Star Strider
Star Strider el 2 de Nov. de 2021
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by