[SciPy-user] surface plotting

Gael Varoquaux gael.varoquaux@normalesup....
Sun Dec 2 10:40:17 CST 2007

On Sun, Dec 02, 2007 at 04:24:50PM +0100, Lorenzo Isella wrote:
> I refer to the text quoted below. I am interested in data representation 
> and 3D plots in particular (something matplotlib is not very suitable for).

Sure. Tell us a bit more about your usecase. Do you want to produce
figures for print/publication, do you want to interact with your data, or
do you want simply to do some 3D plotting in a program of yours. You can
do all this with Mayavi, but the solutions will depend a bit of your usecase.

>The other example I want to discuss is
> (http://www.scipy.org/Cookbook/MayaVi/Surf)

> import numpy
> def f(x, y):
> return numpy.sin(x*y)/(x*y)
> x = numpy.arange(-7., 7.05, 0.1)
> y = numpy.arange(-5., 5.05, 0.05)
> from enthought.tvtk.tools import mlab
> s = mlab.SurfRegular(x, y, f)
> from enthought.mayavi.sources.vtk_data_source import VTKDataSource
> d = VTKDataSource()
> d.data = s.data
> mayavi.add_source(d)
> from enthought.mayavi.filters.warp_scalar import WarpScalar
> w = WarpScalar()
> mayavi.add_filter(w)
> from enthought.mayavi.modules.outline import Outline
> from enthought.mayavi.modules.surface import Surface
> o = Outline()
> s = Surface()
> mayavi.add_module(o)
> mayavi.add_module(s)

> but again,  this is what I get:

> /usr/lib/python2.4/site-packages/scipy/misc/__init__.py:25: 
> DeprecationWarning: ScipyTest is now called NumpyTest; please update 
> your code
>   test = ScipyTest().test
> So far so good
> Traceback (most recent call last):
>   File "3D-enthought.py", line 13, in ?
>     mayavi.add_source(d)
> NameError: name 'mayavi' is not defined

> So, what is going on here? Mayavi is actually installed on my system...

This code has to be run through mayavi. It is suited only for interactive
visualisation or producing figures, and not to run as part of a Python
program. You have to run it in mayavi, either by running "mayavi2 -n -x
script.py", loading it through the menu (File -> Open File), and pressing
Ctrl+R, or entering "execfile('script.py') in the python shell.

> Sorry for the long post. 

No problem, that's what mailing lists are for.

> My main interest is point (1), i.e. to be sure that my python
> installation is still OK (and know what to do in case it is not). 

I think it is OK. What happened is that scipy got updated, and these are
just harmless, albeit annoying, warnings.

> As to point (2), in the end of the day, these modules will make 
> it into debian packages, won't they? 

Yes, we are working on them. I had to finish my PhD thesis, so I was
lagging behind on my work on packaging and Co. I am mostly done with
that (!!), so things will start to move a bit faster soon.

> So at some point installing them should be straightforward (at least
> for me; I am not very good at handling source and installing myself).

Yes, we are working on that. We know it is very important and will focus
effort on ease of instal.



More information about the SciPy-user mailing list