【发布时间】:2020-07-19 06:20:01
【问题描述】:
我希望能够将我的 mayavi 绘图的视图设置为我在交互式窗口中设置的视图。可以使用mlab.view 接口设置视图。但是,我似乎无法从 mayavi 交互式 GUI 中找到视图参数。
在matplotlib 中以交互模式查看绘图时,相机角度和方位角显示在屏幕底部,如下所示:
这很方便,因为要复制我喜欢的视图,我可以读取仰角和方位角并在我的代码中设置它们(在这种情况下使用 ax.view_init(elev=-9, azim=84)。我想在 mayavi 中做同样的事情. 鉴于此代码示例:
from mayavi import mlab
import numpy as np
img = np.random.uniform(0, 255, size=(512, 512)).astype(np.int)
N = 10000
event_size = 2
xs = np.random.uniform(img.shape[1], size=N)
ys = np.random.uniform(img.shape[0], size=N)
ts = np.sort(np.random.uniform(1000, size=N))
ps = np.random.randint(0,2,size=N)
mlab.imshow(img, colormap='gray', extent=[0, img.shape[0], 0, img.shape[1], ts[0], ts[1]])
colors = [0 if p>0 else 240 for p in ps]
ones = np.ones(len(xs))
p3d = mlab.quiver3d(ys, xs, ts, ones, ones,
ones, scalars=colors, mode='sphere', scale_factor=event_size)
p3d.glyph.color_mode = 'color_by_scalar'
p3d.module_manager.scalar_lut_manager.lut.table = colors
mlab.draw()
mlab.show()
此代码应创建图像和点云并将其显示在交互式窗口中。我可以在窗口的哪个位置知道当前的相机参数是什么,以及如何在代码中应用它们? 非常感谢!
【问题讨论】: