I am trying to color a wireframe plot according to the z-value. I can\'t find any code examples on the internet.
Here is an example of a surface plot that has the co
When you use plot_wireframe, each line can only have one color. Instead, you can use plot_surface. To get plot_surface to set the edgecolors, you need to give it facecolors. Then you can set the alpha of facecolors to zero.
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
X, Y, Z = axes3d.get_test_data(0.2)
# Normalize to [0,1]
norm = plt.Normalize(Z.min(), Z.max())
colors = cm.viridis(norm(Z))
rcount, ccount, _ = colors.shape
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, rcount=rcount, ccount=ccount,
facecolors=colors, shade=False)
surf.set_facecolor((0,0,0,0))
plt.show()