Line plots of 3D data #6365
-
I'm trying to recreate an existing plot of a 3D array: for i in range(array.shape[1]):
for j in range(array.shape[2]):
plt.plot(time, array[:, i, j]) but the naive translation
Sort of dropping that restriction from xarray itself, what's the most idiomatic way to do this with xarray? Is there a nice way to iterate over a particular coordinate? Obviously the original method still works, but it doesn't feel very idiomatic! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Maybe just select the wanted entries, something along the line (dimension names have to be changed according to your array):
|
Beta Was this translation helpful? Give feedback.
-
You could maybe also try using |
Beta Was this translation helpful? Give feedback.
You could maybe also try using
stack
to stack the two dimensions you want to loop over into one dimension, before plotting?