[SciPy-User] creating a 3D surface plot from collected data

URI zallen at urologicresearchinstitute.org
Mon Feb 15 09:17:07 EST 2010


I am trying to figure out how to create a 3D surface plot from some x,y,z data
that I have.  I don't have any particular preference as to how to do it, but
from poking around on the web it seems like mplot3d should be able to do it,
based on what I see in the tutorial (look at the wireframe or surface plot
sections):

http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/tutorial.html

The problem I have is that none of the example source code is based on working
with numbers from actual data.  The only thing I could find that addresses this
issue is at the very bottom of this page under the heading "Another Example":
http://www.scipy.org/Cookbook/Matplotlib/mplot3D

I've tried to duplicate this method but I get errors, and I don't really
understand it anyway.  The place I get lost is here:

Z = numpy.zeros((len(Y), len(X)), 'Float32')
for d in data:
   x, y, z = d
   ix = int(x * 10)
   iy = int(y * 10)
   Z[iy, ix] = z


I don't understand how ix and iy are supposed to give me valid indeces for the Z
array (and Python doesn't seem to understand it either, it gives me an error at
that last line).

Can someone either explain this method to me, or point me in a different
direction?




More information about the SciPy-User mailing list