0

I have a 1D array and a 3D array, and I would like to plot the 1D array vs only axis of the 3D matrix array. How do I extract only the first axis of the 3D matrix array? Because when I try to plot, I get this error:

x and y can be no greater than 2-D, but have shapes (710,) and (710, 81, 320)

My 1D array has length of 710, and I want to only plot the first axis with size of 710 for the 3D array. I tried doing:

plt.plot(time[:,None,None], tapered_sla)
plt.show()

where tapered_sla has the size of (710, 81, 320) and time has size of 710. but I still get the same error. Thank you!

Extra information:

The tapered SLA data looks like this:

print(sla_standard.shape)
print(sla_standard[40:42,40:42,40:42])

printed output: 
  sla_tapered shape = (710, 81, 320)

  slice of sla_tapered data:
  [[[-1.4175964  -1.12476448]
  [-0.50547525 -0.80468703]]

  [[-1.49470568 -1.13740495]
  [-0.60470263 -0.86442081]]]

1 Answers1

0

see How to access the ith column of a NumPy multidimensional array?

time[:,0] 

should do the job. : is for the hole array and the second is for the column number.

startpy
  • 36
  • 3
  • Unfortunately I get an error when I do that, saying there are too many indices for array. :/ –  Dec 28 '19 at 15:06
  • hmm - could you post the array? oder a short slice of it like 3 rows...it seems like the array is not like array([[0, 1], [2, 3], [4, 5]]) – startpy Dec 28 '19 at 18:39
  • of course! i will add an extension to the original question! :) –  Dec 28 '19 at 21:20
  • so since the array its 3D and you would like to display coors from 40:42 for each axis...that should be two outputs for each = six. the output dont look like it. So try to split the arrays sla[ : ] [ ] [ ] see https://stackoverflow.com/questions/10668341/create-3d-array-using-python – startpy Dec 28 '19 at 22:13