TransWikia.com

Mayavi imshow obscures quiver3d

Stack Overflow Asked by Mr Squid on December 18, 2021

I am trying to overlay a quiver3d plot over an imshow plot in 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. To illustrate, a GIF:

enter image description here

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:

enter image description here

One Answer

OK, so the solution wound up being switching to nvidia graphics. I was running the code on a laptop with a GeForce GTX 1050 maxQ GPU and Intel on-board graphics. 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.

Answered by Mr Squid on December 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP