enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Difficulty showing plots and very slow loading #1132

Closed mjguzman12 closed 2 years ago

mjguzman12 commented 2 years ago

Hi, I just installed Mayavi and the example plots look very different from the examples. They are very zoomed in and very slow to update when I attempt to change the view. When showing plots, I receive the following message:

qt.qpa.window: <QNSWindow: 0x7fae55cfa220; contentView=<QNSView: 0x7fae57eedee0; QCocoaWindow(0x7fae57e22390, window=QWidgetWindow(0x7fae57ebf9f0, name="QMainWindowClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.

I am using Python 3.8.2 in Spyder in Anaconda - please let me know if I can give you any other information or if you have any thoughts. Thanks!

prabhuramachandran commented 2 years ago

What platform are you doing this on? From your errors this looks like MacOS if so what version of MacOS. I am still on Catalina so cannot comment on the newer versions. You also need to be a bit more specific about the examples you are running. For example if you are using IPython then you absolutely MUST turn on the GUI support with

%gui qt

This is prominently documented here: https://mayavi.readthedocs.io/en/latest/mlab.html

If you are using a script, please be specific about what script/example you tried. Paste the code here.

mjguzman12 commented 2 years ago

Sorry for not being more specific! You are correct, I am using MacOS Big Sur. I found the bug in the example I was running, and I have run some other examples as well. I still receive the error code in my original post when I view a plot, but I am able to interact and save the plot without issue. For reference, the code I am using is as follows, although since the error code doesn't seem to be interfering, I will close this issue. Thank you!

## mean and variance of x

mu_x = 0
variance_x = 1

## mean and variance of y
mu_y = 0
variance_y = 1

## create the base data for the distribution. 
x = np.arange(-3, 3, 0.01)
y = np.arange(-3, 3, 0.01)

## Now, convert X and Y to grids. 
X, Y = np.meshgrid(x, y)
X1 = np.transpose(X)
Y1 = np.transpose(Y)

pos = np.empty(X.shape + (2,))
pos[:, :, 0] = X
pos[:, :, 1] = Y

## simulate the multivariate normal distribution using the parameters
rv = multivariate_normal([mu_x, mu_y], [[variance_x, 0], [0, variance_y]])

theta = np.linspace(start = 0, stop = 2 * np.pi, num = 201)
x = 1*np.cos(theta) + 0
y = 1*np.sin(theta) + 0
height = np.repeat(2, 201)
phi = np.pi

mlab.figure(bgcolor = (1,1,1), fgcolor = (0, 0, 0))
mlab.plot3d(x, y, height, color = (0, 0, 0))
mlab.surf(X1, Y1, rv.pdf(x = pos), warp_scale = 20, colormap = "afmhot")

@mlab.animate(delay = 10)
def anim():
    f = mlab.gcf()
    while 1:
        f.scene.camera.azimuth(0.1)
        f.scene.render()
        yield

a = anim()
mlab.show(stop = True)