Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## matplotlib-users

 [Matplotlib-users] Two 3D surface plots where colors represent same value on both surfaces From: Sammo - 2009-10-02 21:44:51 Attachments: Message as HTML ```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() ```
 [Matplotlib-users] Two 3D surface plots where colors represent same value on both surfaces From: Sammo - 2009-10-02 21:39:49 Attachments: Message as HTML ```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() ```
 Re: [Matplotlib-users] Two 3D surface plots where colors represent same value on both surfaces From: Jae-Joon Lee - 2009-10-04 00:45:41 ```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 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@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ```