简体   繁体   中英

Keep window in Mayavi after running python script

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.

使用mlab.show()保持绘图框打开。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM