Following up the answer provided by Ferguzz, here is a more complete/up-to-date solution:
import matplotlib.colors as colors
import matplotlib.cm as cm
dz = height_values
offset = dz + np.abs(dz.min())
fracs = offset.astype(float)/offset.max()
norm = colors.Normalize(fracs.min(), fracs.max())
color_values = cm.jet(norm(fracs.tolist()))
ax.bar3d(xpos,ypos,zpos,1,1,dz, color=color_values)
Please pay attention to the following points:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…