1

In the code below, I would like to make my graph colorful and add a color scale to it like example 1 below. How do I do this? In other words, I want to take my 3D figure and add color and a scale like the one in Example 1.

Example 1

What my current graph looks like

Here is my code:

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()
Justin
  • 67
  • 6

1 Answers1

1

You need to color the plot itself by supplying a color map to plot_wireframe. Then add the color bar.