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

URI zallen@urologicresearchinstitute....
Wed Feb 17 08:54:10 CST 2010


Joe Kington <jkington <at> wisc.edu> writes:

> 
> 
> No worries about the bottom post. I actually think I'm breaking protocol by
top-posting, but I use gmail, and it's just more natural to top-post.Anyway, I
think your problem is coming from the fact that you're working with an
isosurface that fully encloses a volume. I assumed that you had scattered data
points (say, elevation measurements) that you needed to interpolate between. 
The interpolation example I posted implicitly assumes that z = f(x,y). In other
words, that there is only one z value for any given x and y.  If you're working
with a 3D kidney-shape, this is clearly not the case.  Therefore, you're getting
a singluar matrix when you try to interpolate (more than one value of z for
identical rows of x and y in the matrix).The good news is that this may make the
problem much simpler. (Your data is already in some sort of triangle-strip
format if it's been exported from an imaging program. No need to
interpolate.)What happens when you just do:fig = plt.figure()ax =
Axes3D(fig)ax.plot_surface(x,y,z)plt.show()Where x,y,z are your raw data? 
There's a reasonable chance that the program you used to export the x,y,z
isosurface left the verticies in the order that plot_surface expects them
in...On a side note, you might also look into Mayavi's mlab module for 3D
plotting.  I prefer it to matplotlib's native 3D plotting. If you have it
installed, you'd just do:from enthought.mayavi import mlabs = mlab.mesh(x, y,
z)mlab.show()Hope that helps some,
> -Joe
> On Tue, Feb 16, 2010 at 6:00 AM, URI <zallen <at>
urologicresearchinstitute.org> wrote:
> >Joe Kington <jkington <at> wisc.edu> writes:
> 
> >

I tried using mlab.mesh from mayavi but apparently the x y z components need to
be 2D arrays (see
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#enthought.mayavi.mlab.mesh).

I don't understand this, how can my list of the x-positions of the vertices be a
2D array?

I did try to use mlab.plot3d (see
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#enthought.mayavi.mlab.plot3d)
and it gave me a nice line drawing of my shape, but an actual surface would be
much nicer.



More information about the SciPy-User mailing list