## Re: [Matplotlib-users] Level surface of a function of 3 variables

 Re: [Matplotlib-users] Level surface of a function of 3 variables From: Fernando Perez - 2010-09-18 02:09:06 ```Hi Luke, On Fri, Sep 17, 2010 at 5:49 PM, Dale Lukas Peterson wrote: > >  I'm not sure I understand how I would make use of my function then. >  My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the >  level surfaces (not contour lines) calculated.  I guess I could treat >  z as a parameter, then plot the zero level contour lines of my function for >  a discrete number of z values, but then I would need to adjust the >  height that each countour line is plotted at when I do the 3-d plot. >  This still would only give bunch of vertically stacked contour >  lines, rather than a nice smooth 3-d surface. > >  If I'm misunderstanding what you meant, perhaps you could point me >  to an example of something that makes a level surface of a function >  of 3 (not 2) variables? You're looking for an isosurface; as far as I know matplotlib does not have isosurface modules, only 2-d contours embedded in 3d (such as those illustrated in http://matplotlib.sourceforge.net/examples/mplot3d/contourf3d_demo.html). VTK does have powerful isosurface capabilities, nicely exposed by mayavi: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#contour3d If the mlab helper isn't sufficient for you, you can create directly VTK isosurfaces, the heart example is a good point to start learning: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/example_heart.html Regards, f ```

 [Matplotlib-users] Level surface of a function of 3 variables From: Luke - 2010-09-15 19:02:53 Attachments: Message as HTML ```I have a function of three variables and am interested in plotting the zero level surface: f(x,y,z) = 0 Is there a simple way to plot this level surface in 3-D without having to resort to meshing up x and y, and solving for the z that satisfies the equation? I can do this, but it gets messy because there are anywhere from 0 to 2 solutions to the equation for each point in the x-y plane. The mplot3d examples all seem to calculate the z-data simply from simple functions of x and y. Thanks, ~Luke ```
 Re: [Matplotlib-users] Level surface of a function of 3 variables From: Daπid - 2010-09-16 03:29:13 ```I think you can make it with pyplot.contourf() and the argument V http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contour "contour(Z,V) contour(X,Y,Z,V) draw contour lines at the values specified in sequence V" On Wed, Sep 15, 2010 at 9:02 PM, Luke wrote: > I have a function of three variables and am interested in plotting the zero > level surface: > f(x,y,z) = 0 > Is there a simple way to plot this level surface in 3-D without having to > resort to meshing up x and y, and solving for the z that satisfies the > equation?  I can do this, but it gets messy because there are anywhere from > 0 to 2 solutions to the equation for each point in the x-y plane. > The mplot3d examples all seem to calculate the z-data simply from simple > functions of x and y. > Thanks, > ~Luke > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ```
 Re: [Matplotlib-users] Level surface of a function of 3 variables From: Dale Lukas Peterson - 2010-09-18 00:49:19 ```David, I'm not sure I understand how I would make use of my function then. My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the level surfaces (not contour lines) calculated. I guess I could treat z as a parameter, then plot the zero level contour lines of my function for a discrete number of z values, but then I would need to adjust the height that each countour line is plotted at when I do the 3-d plot. This still would only give bunch of vertically stacked contour lines, rather than a nice smooth 3-d surface. If I'm misunderstanding what you meant, perhaps you could point me to an example of something that makes a level surface of a function of 3 (not 2) variables? Thanks, ~Luke On Thu, Sep 16, 2010 at 05:28:47AM +0200, Daπid wrote: > I think you can make it with pyplot.contourf() and the argument V > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.contour > > "contour(Z,V) > contour(X,Y,Z,V) > > draw contour lines at the values specified in sequence V" > > On Wed, Sep 15, 2010 at 9:02 PM, Luke wrote: > > I have a function of three variables and am interested in plotting the zero > > level surface: > > f(x,y,z) = 0 > > Is there a simple way to plot this level surface in 3-D without having to > > resort to meshing up x and y, and solving for the z that satisfies the > > equation?  I can do this, but it gets messy because there are anywhere from > > 0 to 2 solutions to the equation for each point in the x-y plane. > > The mplot3d examples all seem to calculate the z-data simply from simple > > functions of x and y. > > Thanks, > > ~Luke > > ------------------------------------------------------------------------------ > > Start uncovering the many advantages of virtual appliances > > and start using them to simplify application deployment and > > accelerate your shift to cloud computing. > > http://p.sf.net/sfu/novell-sfdev2dev > > _______________________________________________ > > Matplotlib-users mailing list > > Matplotlib-users@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ```
 Re: [Matplotlib-users] Level surface of a function of 3 variables From: Fernando Perez - 2010-09-18 02:09:06 ```Hi Luke, On Fri, Sep 17, 2010 at 5:49 PM, Dale Lukas Peterson wrote: > >  I'm not sure I understand how I would make use of my function then. >  My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the >  level surfaces (not contour lines) calculated.  I guess I could treat >  z as a parameter, then plot the zero level contour lines of my function for >  a discrete number of z values, but then I would need to adjust the >  height that each countour line is plotted at when I do the 3-d plot. >  This still would only give bunch of vertically stacked contour >  lines, rather than a nice smooth 3-d surface. > >  If I'm misunderstanding what you meant, perhaps you could point me >  to an example of something that makes a level surface of a function >  of 3 (not 2) variables? You're looking for an isosurface; as far as I know matplotlib does not have isosurface modules, only 2-d contours embedded in 3d (such as those illustrated in http://matplotlib.sourceforge.net/examples/mplot3d/contourf3d_demo.html). VTK does have powerful isosurface capabilities, nicely exposed by mayavi: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#contour3d If the mlab helper isn't sufficient for you, you can create directly VTK isosurfaces, the heart example is a good point to start learning: http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/example_heart.html Regards, f ```
 Re: [Matplotlib-users] Level surface of a function of 3 variables From: Jason Grout - 2010-09-18 03:58:17 ```On 9/17/10 9:08 PM, Fernando Perez wrote: > Hi Luke, > > On Fri, Sep 17, 2010 at 5:49 PM, Dale Lukas Peterson > wrote: >> >> I'm not sure I understand how I would make use of my function then. >> My function needs to be evaluated over a 3-d mesh (x, y, and z) , and then the >> level surfaces (not contour lines) calculated. I guess I could treat >> z as a parameter, then plot the zero level contour lines of my function for >> a discrete number of z values, but then I would need to adjust the >> height that each countour line is plotted at when I do the 3-d plot. >> This still would only give bunch of vertically stacked contour >> lines, rather than a nice smooth 3-d surface. >> >> If I'm misunderstanding what you meant, perhaps you could point me >> to an example of something that makes a level surface of a function >> of 3 (not 2) variables? > > You're looking for an isosurface; as far as I know matplotlib does not > have isosurface modules, only 2-d contours embedded in 3d (such as > those illustrated in > http://matplotlib.sourceforge.net/examples/mplot3d/contourf3d_demo.html). > > VTK does have powerful isosurface capabilities, nicely exposed by mayavi: > > http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#contour3d Sage will also do this sort of thing, though it's not as powerful as VTK/Mayavi in this functionality: http://www.sagemath.org/doc/reference/sage/plot/plot3d/implicit_plot3d.html Here are lots of sheets on sagenb.org that use implicit_plot3d somewhere: http://sagenb.org/pub/?typ=pub&search=implicit_plot3d Thanks, Jason ```