mayavi questions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mayavi questions

j brandon keith
hi...i've been using mayavi for several days and can't seem to find a
way to do the following:
*tick marks on almost any plot--can't find a single example on web with them
*how to do surfaces over irregularly spaced data points...i have a
hunch this should be something along the lines of scalar_scatter, then
delauny2D, etc.....but so far haven't even gotten the first one to
work...

brandon

ps: i like mayavi overall, it just needs more doc
examples...especially non-flow-visualization ones...
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: mayavi questions

Erik Tollerud
Hello,

> *tick marks on almost any plot--can't find a single example on web with them
Have you tried mlab.axes() ?  Or you mean you want tick marks on those
axes?  (If the latter, I don't know how to do it...)

> *how to do surfaces over irregularly spaced data points...i have a
> hunch this should be something along the lines of scalar_scatter, then
> delauny2D, etc.....but so far haven't even gotten the first one to
> work...
Unfortunately, my experience has been that this is a highly
data-dependent problem.  I assume your problem here is that you have a
bunch of data points with associated scalar values (e.g. an
irregularly sampled 3D scalar field), and you want constant value
surfaces, is that correct?  One way you can do this is below... I'm
generating fake data that is just a gaussian field sampled on an
irregular grid:

>>> from enthought.mayavi import mlab
>>> from numpy.random import randn
>>> from numpy import exp

>>> x,y,z = randn(3,1000)
>>> scalar = exp(-x*x-y*y-z*z)
>>> ss = mlab.pipeline.scalar_scatter(x,y,z,scalar)
>>> del3d = mlab.pipeline.delaunay3d(ss)

You can now visualize the delaunay triangulartion.  Say for example, a
scalar cut plane :

>>> mlab.pipeline.scalar_cut_plane(del3d)

Or alternatively, an isosurface works decently for this case:

>>> iso = mlab.pipeline.iso_surface(del3d)
>>> iso.contour.auto_contours = True
>>> iso.contour.number_of_contours = 3
>>> iso.actor.property.opacity = .5
>>> iso.contour.minimum_contour = .2
>>> iso.contour.maximum_contour = .7


Now if your data is too irregular or otherwise weird to get a good
Delaunay triangulation (almost always the case for when I've done
this), you can re-sample the data into a regular grid and start using
volume-visualization techniques with mlab.pipeline.scalar_field, which
IMHO are often more robust and useful.  You can do this with
mlab.pipeline.gaussian_splatter if the data volume isn't too large,
but for much of what I've worked with, it's better to just write your
own code to resample and then just load the resampled field
directly...
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: mayavi questions

Gael Varoquaux
In reply to this post by j brandon keith
On Thu, Apr 01, 2010 at 11:18:24AM -0700, j brandon keith wrote:
> hi...i've been using mayavi for several days and can't seem to find a
> way to do the following:
> *tick marks on almost any plot--can't find a single example on web with them

I am not sure what you want to do. Most of the 'ticking' functionnality
is provided by the axes module, that you can access using mlab.axes
http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_other_functions.html#axes

> *how to do surfaces over irregularly spaced data points...i have a
> hunch this should be something along the lines of scalar_scatter, then
> delauny2D, etc.....but so far haven't even gotten the first one to
> work...

Hopefuly Erik gave you a good head start. However, if what you are trying
to is more to 'connect the dots on a surface' than to 'iso-surface
aftering interpolating between points', you might find the following
example helpful:

http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_surface_from_irregular_data.html

HTH,

Gaƫl
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev