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)

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.

On Fri, Oct 2, 2009 at 5:44 PM, Sammo <sammo2828@...287...> 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 matplotlib-users List Signup and Options