[SciPy-user] Simple plot problem

Gael Varoquaux gael.varoquaux@normalesup....
Tue Feb 17 07:02:24 CST 2009


On Tue, Feb 17, 2009 at 04:05:25AM -0800, Guilherme P. de Freitas wrote:
> My version of Mayavi is 3.0.3.

OK, that might be in the default scaling of surf that has changed between
the 3.0.3 and the 3.1.0 (I can't get my hands on an install of 3.0.3, and
I don't want to downgrade the boxes at work). If you don't want to
upgrade the version of mayavi, you can try to force the extent, as in the
following code:

################################################################################
import numpy as np
from enthought.mayavi import mlab

x, y = np.mgrid[0:3:100j, 0:3:100j]
def f(x, y):
    return x**(0.3) * y**(0.7)
mlab.surf(x, y, f, extent=[0, 3, 0, 3, 0, f(x, y).max()])

x = np.linspace(0, 1, 100)
mlab.plot3d(x, 2-2*x, np.zeros_like(x))
mlab.plot3d(x, 2 - 2*x, f(x, 2 - 2*x))
mlab.show()
################################################################################

Do note that the docs on the web are for the 3.1.0 version. There are
some small differences, and you seem to have hit a version where we made
a change in auto-scaling based on user experience.

Please tell me if the above code works for you.

Cheers,

Gaël


More information about the SciPy-user mailing list