简体   繁体   English

运行python脚本后在Mayavi中保留窗口

[英]Keep window in Mayavi after running python script

I'm trying to run a python script that generates a plot using Mayavi. 我正在尝试运行一个使用Mayavi生成图的python脚本。

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: 这似乎足够合理,但是当我尝试这样做时,python报告:

AttributeError: 'module' object has no attribute 'mayavi'

any ideas? 有任何想法吗? I'm using the standard Enthought Python on OS X. 我在OS X上使用标准的Enthought Python。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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