首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用mayavi时,如何删除scalar_cut_plane中的红框和白箭头?

使用mayavi时,如何删除scalar_cut_plane中的红框和白箭头?
EN

Stack Overflow用户
提问于 2015-01-30 10:44:50
回答 2查看 364关注 0票数 0

嗨,我想使用mayavi在一个切割平面中的结构化网格中可视化数据。

为了举例说明这一点,我从Eric编写的grid.html中获得了以下代码

代码语言:javascript
复制
#!/usr/bin/env python  
import numpy as np
from numpy import cos, sin, pi
from tvtk.api import tvtk
from mayavi import mlab

def generate_annulus(r=None, theta=None, z=None):
    # Find the x values and y values for each plane.
    x_plane = (cos(theta)*r[:,None]).ravel()
    y_plane = (sin(theta)*r[:,None]).ravel()

    # Allocate an array for all the points.  We'll have len(x_plane)
    # points on each plane, and we have a plane for each z value, so
    # we need len(x_plane)*len(z) points.
    points = np.empty([len(x_plane)*len(z),3])

    # Loop through the points for each plane and fill them with the
    # correct x,y,z values.
    start = 0
    for z_plane in z:
        end = start + len(x_plane)
        # slice out a plane of the output points and fill it
        # with the x,y, and z values for this plane.  The x,y
        # values are the same for every plane.  The z value
        # is set to the current z
        plane_points = points[start:end]
        plane_points[:,0] = x_plane
        plane_points[:,1] = y_plane
        plane_points[:,2] = z_plane
        start = end

    return points

# Make the data.
dims = (51, 25, 25)
# The coordinates
theta = np.linspace(0, 2*np.pi, dims[0])
# 'y' corresponds to varying 'r'
r = np.linspace(1, 10, dims[1])
z = np.linspace(0, 5, dims[2])
pts = generate_annulus(r, theta, z)

# Make the grid
sgrid = tvtk.StructuredGrid(dimensions=dims)
sgrid.points = pts
s = np.sqrt(pts[:,0]**2 + pts[:,1]**2 + pts[:,2]**2)
sgrid.point_data.scalars = np.ravel(s.copy())
sgrid.point_data.scalars.name = 'scalars'

d = mlab.pipeline.add_dataset(sgrid)
mlab.pipeline.scalar_cut_plane(d)
mlab.show()

然而,我想摆脱恼人的红色框架和白色箭头时,在保存情节。我该怎么做?

我第一次尝试使用模块mlab.pipeline.scalar_field来完成这个任务,但是我发现了一个错误:我需要将数据指定为数组。我还搜索了盖伊,看看是否有什么地方我可以关掉它,但我似乎找不到

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-30 12:54:00

您可以简单地禁用小部件。不过,请注意,这意味着您不能再拖曳飞机(但听起来您不想拥有此功能)。

在最后一行,更改

代码语言:javascript
复制
mlab.pipeline.scalar_cut_plane(d)

使用

代码语言:javascript
复制
cut = mlab.pipeline.scalar_cut_plane(d)
cut.implicit_plane.widget.enabled = False

在GUI中也可以这样做。

转到管道菜单中的ScalarCutPlane,然后取消选中选项卡"ImplicitPlane“中的"enable”,从而禁用小部件。

...and给你

票数 0
EN

Stack Overflow用户

发布于 2020-12-08 23:50:50

您可以通过添加以下内容使其更好:

代码语言:javascript
复制
cut = mlab.pipeline.scalar_cut_plane(d)
input('Press any key to snap in . . .')
cut.implicit_plane.widget.enabled = False

现在你可以把你想要的位置放在第一位。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28234146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档