matplotlib - 3d surface from a rectangular array of heights

Viewed 28104

I am trying to plot some HDF data in matplotlib. After importing them using h5py, the data is stored in a form of array, like this:

array([[151, 176, 178],
       [121, 137, 130],
       [120, 125, 126])

In this case, x and y values are just the indexes of the array's fields, while z value is the value of specific field. In the (x,y,z) form it would look like:

(1,1,151)
(2,1,176)
(3,1,178)
(1,2,121)
...

and so on.

Is there an easy way to do a surface plot from this kind of data? I know I can change this to (x,y,z) tuples by iterating all over the array, but maybe it is not needed?

1 Answers
Related