enthought / mayavi

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

Problem getting started with Mayavi #1307

Closed physudipsics closed 1 week ago

physudipsics commented 1 week ago

Hello all,

I am using Anaconda distribution (Python 3.11.5), and want to use mayavi to visualize some data. I have tried with the following:

pip install vtk pip install mayavi

The screen outputs of the same are attached herewith.

image

After that I tried with the following example code:

# Create the data.
from numpy import pi, sin, cos, mgrid
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta)

# View it.
from mayavi import mlab
s = mlab.mesh(x, y, z)
mlab.show()

The output is attached below:

image

Could you please help me fix this?

Thank you.

physudipsics commented 1 week ago

The issue resolved. I uninstalled the Anaconda Python and reinstalled it.

Then I followed:

`pip install vtk pyqt5

pip install mayavi`

It fixed the problem.