Re: [SciPy-user] surface plotting
![](https://secure.gravatar.com/avatar/937c833e374adb46b19fa5febb027c79.jpg?s=120&d=mm&r=g)
Well, I was hoping for a lighter solution, but I gave it a one-hour try. It didn't help that when I did the link to the user docs was broken (it's fixed now). I got so far as installing mayavi2 and trying to figure it out without the doc, but ran out of time and wasn't able to figure out surface plotting my existing numpy array. This was for use in a class and I decided that if I couldn't figure out how to do it in an hour I probably couldn't expect the students to do it at all. It would be good to have a cookbook recipe about how to do surface plotting of a 2D numpy array in mayavi2. When will mayavi2 be available as a deb file? This looks like software that everyone should be able to get in the easiest fashion possible. Thanks, --jh--
![](https://secure.gravatar.com/avatar/4f71fba1231b38e31020ed481bebccf9.jpg?s=120&d=mm&r=g)
On Nov 30, 2007 2:00 PM, Joe Harrington <jh@physics.ucf.edu> wrote:
It would be good to have a cookbook recipe about how to do surface plotting of a 2D numpy array in mayavi2.
For the purposes of your class, I find that a simple imshow or pcolor of 2D data with a color map is usually good enough to visualize a 2D array. Surf doesn't really add much unless you are interactively panning and zooming, when the movement generates extra 3D visual cues. JDH
![](https://secure.gravatar.com/avatar/4049498c84d4a7a8f5f5afa5b86c4d2b.jpg?s=120&d=mm&r=g)
Joe Harrington a écrit :
It would be good to have a cookbook recipe about how to do surface plotting of a 2D numpy array in mayavi2.
http://www.scipy.org/Cookbook/MayaVi/Surf http://www.scipy.org/Cookbook/MayaVi/mlab
When will mayavi2 be available as a deb file? It's coming... :-)
HTH. Cheers, -- http://scipy.org/FredericPetit
![](https://secure.gravatar.com/avatar/1fb17de2e01c86df878d18f517e09210.jpg?s=120&d=mm&r=g)
fred wrote:
Joe Harrington a écrit :
It would be good to have a cookbook recipe about how to do surface plotting of a 2D numpy array in mayavi2.
http://www.scipy.org/Cookbook/MayaVi/Surf http://www.scipy.org/Cookbook/MayaVi/mlab
Unfortunately, these still use tvtk's mlab which is lower level and not as powerful as mayavi's new mlab. The best docs for that are here: https://svn.enthought.com/enthought/attachment/wiki/MayaVi/mlab.pdf cheers, prabhu
![](https://secure.gravatar.com/avatar/5c9fb379c4e97b58960d74dcbfc5dee5.jpg?s=120&d=mm&r=g)
On Sat, Dec 01, 2007 at 10:24:42PM +0530, Prabhu Ramachandran wrote:
Unfortunately, these still use tvtk's mlab which is lower level and not as powerful as mayavi's new mlab.
The best docs for that are here:
https://svn.enthought.com/enthought/attachment/wiki/MayaVi/mlab.pdf
Quickly, you can have a feeling of how to plot surface using mlab by folliwing these steps: run "ipython -wthread" execute the following python code: +++++++++++++++++++++++++++++++++++++++ In [1]: from enthought.mayavi.tools import mlab as M Set Envisage to use the workbench UI: True Set Envisage to use the workbench UI: True In [2]: from scipy import * In [3]: X, Y = mgrid[-1:1:50j, -1:1:50j] In [4]: Z = cos(4*(X**2+Y**2)) In [5]: M.surf(X, Y, Z) +++++++++++++++++++++++++++++++++++++++ This will bring up a Mayavi2 window with the surface plotted. The mlab API is similar to matplotlib's pylab, so you should feel quite familiar with it. It is still young and I haven't had time to put as much work as I would like in it. Documentation is lacking, but the docstrings are quite good. Just reading "help(M)" in the example above should hopefully give you an idea of the possbilities. The docs pointed to by Prabhu should also be helpful. HTH, Gaël
![](https://secure.gravatar.com/avatar/b9ecebc4f08c154889502da137c71e0c.jpg?s=120&d=mm&r=g)
Can Mayavi2 be called from within a wxpython application for 3D plotting? At one point I did this with tvtk (using pyface, etc), but not with mayavi. How different is the mlab within tvtk from that in mayavi2? Thanks, William On Dec 2, 2007 11:49 AM, Gael Varoquaux <gael.varoquaux@normalesup.org> wrote:
On Sat, Dec 01, 2007 at 10:24:42PM +0530, Prabhu Ramachandran wrote:
Unfortunately, these still use tvtk's mlab which is lower level and not as powerful as mayavi's new mlab.
The best docs for that are here:
https://svn.enthought.com/enthought/attachment/wiki/MayaVi/mlab.pdf
Quickly, you can have a feeling of how to plot surface using mlab by folliwing these steps:
run "ipython -wthread"
execute the following python code:
+++++++++++++++++++++++++++++++++++++++ In [1]: from enthought.mayavi.tools import mlab as M Set Envisage to use the workbench UI: True Set Envisage to use the workbench UI: True
In [2]: from scipy import *
In [3]: X, Y = mgrid[-1:1:50j, -1:1:50j]
In [4]: Z = cos(4*(X**2+Y**2))
In [5]: M.surf(X, Y, Z) +++++++++++++++++++++++++++++++++++++++
This will bring up a Mayavi2 window with the surface plotted. The mlab API is similar to matplotlib's pylab, so you should feel quite familiar with it. It is still young and I haven't had time to put as much work as I would like in it. Documentation is lacking, but the docstrings are quite good. Just reading "help(M)" in the example above should hopefully give you an idea of the possbilities. The docs pointed to by Prabhu should also be helpful.
HTH,
Gaël _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/5c9fb379c4e97b58960d74dcbfc5dee5.jpg?s=120&d=mm&r=g)
On Sun, Dec 02, 2007 at 12:56:47PM -0500, william ratcliff wrote:
Can Mayavi2 be called from within a wxpython application for 3D plotting?
Yes. This has been one of the great additions of this summer. Have a look at https://svn.enthought.com/enthought/browser/branches/enthought.mayavi_2.0.3a... for a demo of how mayavi is integrated in a traits application. As traits relies on WxPython (althought, there is now a Qt front end), it is trivial to plug this in a WxPython applictation (ask if you need help).
At one point I did this with tvtk (using pyface, etc), but not with mayavi. How different is the mlab within tvtk from that in mayavi2?
I more and more think of the mayavi engine as an abstraction over tvtk that allows one to think in terms of data and visualisation rather than in terms of VTK objects. The mayavi2 application is a GUI around the mayavi2 engine. The example above exposes the engine without the GUI, allowing you to use its nice API and features in you own app. Mlab is a simplied API for Mayavi that tries to mimic pylab/matlab. The calls are really simple and easy to learn. However, due to a design error on my side, mlab cannot be used in a standalone way, ie to integrate in an existing WxPython app. This will be changed, just give me a month or two (not that there is a huge amount of work, but that I am very busy). It is much easier to add features to mayavi's mlab than to tvtk's. Moreover, with mayavi's mlab you can pop up the UI to edit the pipeline in your own app, you also have the engine API that you can access, and this is great to update/modify a visualization. I think the big difference between the two is the presence of the mayavi2 engine, which give a nice abstraction on the visulization. As a result, mayavi's mlab already has more features than tvtk's, altought some features of tvtk's mlab are missing (mainly the ability to run in standalone). HTH, Ga�l
![](https://secure.gravatar.com/avatar/1fb17de2e01c86df878d18f517e09210.jpg?s=120&d=mm&r=g)
Gael Varoquaux wrote:
On Sun, Dec 02, 2007 at 12:56:47PM -0500, william ratcliff wrote:
Can Mayavi2 be called from within a wxpython application for 3D plotting?
Yes. This has been one of the great additions of this summer. Have a look at https://svn.enthought.com/enthought/browser/branches/enthought.mayavi_2.0.3a... for a demo of how mayavi is integrated in a traits application. As traits relies on WxPython (althought, there is now a Qt front end), it is trivial to plug this in a WxPython applictation (ask if you need help).
I wouldn't say it is "trivial" but certainly relatively easy to do. The best place to ask would be on the enthought-dev list.
At one point I did this with tvtk (using pyface, etc), but not with mayavi. How different is the mlab within tvtk from that in mayavi2? [...] allowing you to use its nice API and features in you own app. Mlab is a simplied API for Mayavi that tries to mimic pylab/matlab. The calls are really simple and easy to learn. However, due to a design error on my side, mlab cannot be used in a standalone way, ie to integrate in an existing WxPython app. This will be changed, just give me a month or two (not that there is a huge amount of work, but that I am very busy).
Right, I don't think it should be too hard to port mlab to use the raw engine. There are a few design issues Gael and I will need to sort out about how best to do this though. As Gael said, both of us are currently tied up it may take a month or two for this to actually happen. cheers, prabhu
![](https://secure.gravatar.com/avatar/1fb17de2e01c86df878d18f517e09210.jpg?s=120&d=mm&r=g)
Joe Harrington wrote:
Well, I was hoping for a lighter solution, but I gave it a one-hour try. It didn't help that when I did the link to the user docs was broken (it's fixed now). I got so far as installing mayavi2 and trying to figure it out without the doc, but ran out of time and wasn't able to figure out surface plotting my existing numpy array. This was for use in a class and I decided that if I couldn't figure out how to do it in an hour I probably couldn't expect the students to do it at all.
Sorry about the mess with installation instructions etc. I'm trying to get some help regarding this but I've been too busy otherwise to do much about it -- end of semester here. I'm hoping to try and get something done about it over the next couple of weeks. One of the easiest ways to get things installed without eggs right now is to first install the dependencies -- wxPython 2.6, python-vtk and numpy and then grab the tarballs here: http://code.enthought.com/downloads/source/ets2.6/ Untar them and build them each cd enthought.traits ./build.sh vi/emacs install.sh ./install.sh for all the tarballs and you should have mayavi installed. The script is broken in that it does not install the mayavi executable though -- need to fix that.
It would be good to have a cookbook recipe about how to do surface plotting of a 2D numpy array in mayavi2.
mayavi.tools.mlab.surf should help here.
When will mayavi2 be available as a deb file? This looks like software that everyone should be able to get in the easiest fashion possible.
Ondrej Certik has been very helpful in making preliminary debs that we hope will soon get into debian. You can find a older versions here: http://debian.certik.cz/ I sent Ondrej patches to fix some of the issues but don't see new versions yet. Ondrej did say he was busy... cheers, prabhu
participants (6)
-
fred
-
Gael Varoquaux
-
Joe Harrington
-
John Hunter
-
Prabhu Ramachandran
-
william ratcliff