我正在尝试覆盖一个quiver3d
绘制在imshow
情节在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()
我遇到的问题是imshow
图像似乎完全模糊了quiver
情节,即使“箭袋”位于图像顶部。为了说明这一点,GIF:
我究竟做错了什么?提前谢谢了!
====编辑====
这也是我的实际用例中的 GIF,我认为它比上面的最小示例更好地说明了问题: