I am new here, please be gentle. I am doing a project which requires me to draw the figure of octupole. I used python surface plot and got a result like this:
However, my professor wants something like this:
Please ignore the 226Ra in the figure. I want to change the color of my plot to red, and add the grid lines like that. Is there any way I can do it? I would be very appreciated. Here's my code:
import numpy as np;
from matplotlib import cm, colors;
import cmath;
import matplotlib.pyplot as plt;
from mpl_toolkits.mplot3d import Axes3D;
import scipy.special as sp;
l = 3 # degree
m = 0 # order
PHI, THETA = np.mgrid[0:2*np.pi:300j, 0:np.pi:150j]
R = sp.sph_harm(m, l, PHI, THETA).real
s = 1
X = (s*R*0.28+1) * np.sin(THETA) * np.cos(PHI)
Y = (s*R*0.28+1) * np.sin(THETA) * np.sin(PHI)
Z = (s*R*0.29+1) * np.cos(THETA)
norm = colors.Normalize()
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'), figsize=(14,10))
m = cm.ScalarMappable(cmap=cm.jet)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=cm.jet(norm(R)))
m.set_array(R)
fig.colorbar(m, shrink=0.8);
Just replace your plot_surface
line with the following and comment out fig.colorbar(m, shrink=0.8);
. You can use any other color as per your wish from this page.
ax.plot_surface(X, Y, Z, rstride=10, cstride=10, color='orangered', edgecolors='k', lw=0.6)
Output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With