What you need to do is to share a normalizer among different surface plots (this is not just for surface plot, but for all (as far as I know) color representation that uses colormaps). Note that "norm" can also be a keyword argument.
Regards, -JJ Z1 = 5*np.sin(R) s1 = ax.plot_surface(X, Y, Z1, rstride=1, cstride=1, cmap=cm.jet) mynorm = s1.norm Z2 = np.cos(R) s2 = ax.plot_surface(X, Y, Z2, rstride=1, cstride=1, cmap=cm.jet) s2.set_norm(mynorm) mynorm.vmax = max(Z1.max(), Z2.max()) mynorm.vmin = min(Z1.min(), Z2.min()) On Fri, Oct 2, 2009 at 5:44 PM, Sammo <sammo2...@gmail.com> wrote: > 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(X**2 + Y**2) > > Z = 5*np.sin(R) > ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) > > Z = np.cos(R) > ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet) > > plt.show() > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users