fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X ** 2 + Y ** 2)
Z = np.sin(R)
Gx, Gy = np.gradient(Z)
G = (Gx ** 2 + Gy ** 2) ** 0.5
N = G / G.max()
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=cm.jet(N),
    linewidth=0, antialiased=False, shade=False)
plt.show()
Color matplotlib plot_surface command with surface gradient