How do I plot the surface of a 4D plot?

2.4k views Asked by At

I am trying to plot the wave function for a particle in a 3D box. This requires me to plot 4 variables: x, y, z axes and the probability density function.

The probability density function is:

abs((np.sin((p*np.pi*X)/a))*(np.sin((q*np.pi*Y)/b))*(np.sin((r*np.pi*Z)/c)))**2

I am using np.arange() for the X, Y and Z.

I have read that to do this you need to plot the surface of a 4D plot. Here is what it is supposed to look like:

enter image description here

2

There are 2 answers

1
pierre On BEST ANSWER

You want to plot a 3D scalar field f(x,y,z) against all three spatial coordinates. I am not sure what you're precisely willing to do: which surfaces are you talking about ? You may want to plot iso-density surfaces, which allow for clear visualization of the field. I don't know the Matplotlib formulation for this, but with Mayavi2 (a great 3D-plotting Python library) you can use "contour3d" : http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#mayavi.mlab.contour3d

Anyway if you're willing to do advanced 3D stuff Mayavi is way better than Matplotlib. See the gallery for examples : http://docs.enthought.com/mayavi/mayavi/auto/examples.html

Hope that helps !

3
JonathanV On

Are these plots essentially plots allowing three of the variables to vary freely while fixing one of the variables and then cycling through all four? If so then these plots could be achieved using matplotlib.Axes3d or the like?