I'm trying to run a python script that generates a plot using Mayavi.
I'm using the following example code to generate an iso-surface plot:
from mayavi import mlab
def test_contour3d():
x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, -5:5:64j]
scalars = x * x * 0.5 + y * y + z * z * 2.0
obj = mlab.contour3d(scalars, contours=4, transparent=True)
return obj
test_contour3d()
The plot looks great but it immediately disappears. I read that you need to include the following code in order to make the plot stick around:
import mayavi
v = mayavi.mayavi()
v.master.wait_window()
This seems reasonable enough, but when I try this, python reports:
AttributeError: 'module' object has no attribute 'mayavi'
any ideas? I'm using the standard Enthought Python on OS X.
Use mlab.show() to keep the plot frame open.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With