16 Jul 23:54
Modify surf output (axes, scaling)
From: Thomas Königstein <thkoe002@...>
Subject: Modify surf output (axes, scaling)
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-07-16 21:57:56 GMT
Subject: Modify surf output (axes, scaling)
Newsgroups: gmane.comp.python.enthought.devel
Date: 2008-07-16 21:57:56 GMT
Hello everyone,
I recently started using mayavi2 (and I'm also kind of new to python, couple of months), and now I'm "stuck" with a couple of (hopefully trivial) problems.
The problem is this: I'm plotting a particle density over a small area, using enthought.mayavi.mlab.surf. Now I can either call the method with
>>> surf(my_data) #method a)
where my_data is a two dimensional numpy.ndarray containing the density, or with
>>> surf(x,y,my_data) #method b)
where x and y are declared via numpy.mgrid so that the coordinates represent the physical coordinates instead of just [1,2,3,... ] as in the first case.
Now, with either method, I have the problem when the values of the x,y coordinates are of a different magnitude (i.e. much bigger/smaller) as the value of the z- (i.e. my_data)-coordinate. (For example, x,y being micrometer --> around 1.e-6 while z is around 1e4, or x,y being [1,2,3,...] while z is ~1e-10) So when I view the plot, I get either a thin line when my_data is much bigger than x,y; or I get a flat plane when my_data is negligible compared to x,y. Only when they by chance happen to have the same magnitude, the 3d outline is a nice cuboid.
A solution is to use the "WarpScalar" filter to shrink/expand the z-axis, but then the values also change, and the z-axis becomes useless. It's also possible to change the "Spacing" for x,y (changing z seems to be broken for me here) in the "Array2DSource" object editor, but then the x,y values become incorrect. So, my question is: How can I change the height of a graph without changing the values?
(Minimum working example: from numpy import zeros;from enthought.mayavi.mlab import surf;g=numpy.zeros((2,2));g[0][0]=1e5;surf(g) )
The second problem is somewhat related. Using method b) from above, when my grid has the extension of 1e-5 or so, it becomes hard to zoom in and turn the plot, and there are graphical glitches (see http://i34.tinypic.com/2efi876.png , 600kb png). This happens even when the origin of the source object is at (0,0,0). Sometimes, the plot is also kind of "jagged". So my question is: how can I produce a decent plot when the x,y grid is very small?
(Example: from numpy import zeros,mgrid;from enthought.mayavi.mlab import surf;x,y=mgrid[0:3e-5:10j,0:3e-5:10j];g=zeros((10,10));surf(x,y,g) #you'll have to click "obtain an isometric view" and then move the mouse around a bit to find the surface)
Thanks in advance, cheers
Thomas
ps. I just want to recommend www.pythonxy.com for anyone who wants to quickly install mayavi2 and pretty much every other python environment that's useful for scientific applications.
_______________________________________________ Enthought-dev mailing list Enthought-dev@... https://mail.enthought.com/mailman/listinfo/enthought-dev
RSS Feed