在下面的代码中,我想使我的图形丰富多彩,并像下面的示例1一样向其添加一个色标。我该怎么做呢?换句话说,我想获取3D图形并添加颜色和比例,如示例1所示。
What my current graph looks like
这是我的代码:
import matplotlib as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from test4 import model_brdf2
#from test4 import theta_i_uniq
#from test4 import theta_r_uniq
#from test4 import phi_r_uniq
def polar2cart(rho,theta,phi):
x = rho* np.sin(theta)*np.cos(phi)
y = rho *np.sin(theta)*np.sin(phi)
z = rho *np.cos(theta)
return(x,y,z)
theta_r_uniq = np.deg2rad(np.linspace(-80,80))
phi_r_uniq = np.deg2rad(np.linspace(-180, 180))
Theta_grid, Phi_grid = np.meshgrid(theta_r_uniq, phi_r_uniq)
nrows, ncols = Theta_grid.shape
#Theta_grid = Theta_grid.flatten()
#Phi_grid = Phi_grid.flatten()
fig = plt.figure()
ax = plt.axes(projection="3d")
theta_i_rad = np.deg2rad(-60.0)
r_brdf = model_brdf2(theta_i_rad,0,Theta_grid,Phi_grid)
Xgrid, Ygrid, Zgrid = polar2cart(r_brdf,Theta_grid, Phi_grid)
#z = np.cos(Theta_grid) #+ np.sin(Phi_grid)
#ax.plot3D(Xgrid, Ygrid, z, )
ax.plot_wireframe(Xgrid, Ygrid, Zgrid)
plt.show()
在下面的代码中,我想使我的图形丰富多彩,并像下面的示例1一样向其添加一个色标。我该怎么做呢?换句话说,我想拍摄3D图形并添加颜色和比例,例如...
您需要用supplying a color map to plot_wireframe
给图本身上色。然后plot_wireframe
。