0
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

u = np.linspace(0,2*np.pi,100)
v = np.linspace(0,0.5*np.pi,50)
R0 = 1 
xhf = R0*np.outer(np.cos(u),np.sin(v))
yhf = R0*np.outer(np.sin(u),np.sin(v))
zhf = R0*np.outer(np.ones(np.size(u)),np.cos(v))
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
ax.plot_surface(xhf,yhf,zhf,rstride=5,cstride=5,cmap=cm.coolwarm)
plt.show()

I can use the above code to draw a semi-spherical surface, the color is assigned by the scale of the z coordinate. But i want to use the color to show another aspect of the surface, like the density, temperature distribution, etc. BTW, I have got that parameter distribution on the surface.

Snowbug
  • 11
  • 2
  • Use the `facecolors` kwarg. See [here](https://matplotlib.org/examples/mplot3d/surface3d_demo3.html) for an example how to do that. – tmdavison Oct 02 '17 at 14:21
  • Yes. But how can i develop the relation between the **color** wiht my **density value**? Thanks you. – Snowbug Oct 03 '17 at 01:03

0 Answers0