 # Two 3D surface plots where colors represent same value on both surfaces

How do I draw two 3D surface plots where the surface patch colors have consistent meaning?

Hope this makes sense …

Currently, I’m just doing two plot_surface commands, each of which has cmap=cm.jet. The two surfaces have different shapes and sizes and have different highest/lowest points. It seems that the colormap is automatically normalised to the highest/lowest values for each surface independently (e.g. the highest point on both surfaces is red, even though they are different values). Instead, I want the same color to represent the same value on both surfaces.

Any ideas will be appreciated. Perhaps there’s a way to force the colormap to be normalised to a specified range of values?

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X2 + Y2)

Z = 5*np.sin®
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)

Z = np.cos®
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)

plt.show()