简体   繁体   English

Mayavi imshow 掩盖了 quiver3d

[英]Mayavi imshow obscures quiver3d

I am trying to overlay a quiver3d plot over an imshow plot in mayavi .我正在尝试将quiver3d plot 覆盖在 mayavi 中的imshow mayavi上。 The code I am using looks something like this:我正在使用的代码如下所示:

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()

The issue I have with it, is that the imshow image seems to completely obscure the quiver plot, even when the 'quivers' are on top of the image.我遇到的问题是, imshow图像似乎完全掩盖了quiver plot,即使“箭袋”位于图像顶部也是如此。 To illustrate, a GIF:为了说明,一个GIF:

在此处输入图像描述

What am I doing wrong?我究竟做错了什么? Many thanks in advance!提前谢谢了!

==== EDIT ==== Here is also a GIF from my actual use case, I think it illustrates the problem better than the minimal example above: ==== 编辑 ==== 这也是我实际用例的 GIF,我认为它比上面的最小示例更好地说明了问题:

在此处输入图像描述

OK, so the solution wound up being switching to nvidia graphics.好的,所以最终解决方案是切换到 nvidia 图形。 I was running the code on a laptop with a GeForce GTX 1050 maxQ GPU and Intel on-board graphics.我在配备 GeForce GTX 1050 maxQ GPU 和英特尔板载显卡的笔记本电脑上运行代码。 With on-board graphics ( sudo prime-select intel ), I get the bug, when I switch to dedicated graphics ( sudo prime-select nvidia ) I get the desired output.使用板载图形( sudo prime-select intel ),我得到了错误,当我切换到专用图形( sudo prime-select nvidia )时,我得到了所需的 output。

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

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