On 07/26/2010 10:13 AM, Nikolaus Rath wrote:
Hello,
I would like to draw a couple of contour plots. The plots are on
separate figures, but they should all have exactly the same color
mapping (i.e, the same Z value should correspond to the same color in
all plots).
What's the best way to achieve this?
I think that all you will need is to specify the same cmap (if you are
not using the default) and contour levels for both plots. You should
not need to use the norm, unless you are doing something fancy; and in
that case, all you need to do is specify the same norm for both plots.
The real key, though, is explicitly specifying the set of contour levels
that you want, and using the same one for both plots.
e.g.:
from pylab import * # yes, this is not recommended...
clevs = arange(0.3, 0.701, 0.1)
fig1 = figure()
contourf(rand(20,20), levels=clevs, extend='both')
colorbar()
fig2 = figure()
contourf(rand(30,40), levels=clevs, extend='both')
colorbar()
show()
You need to use the extend argument only if you want values beyond the
levels you specify to constitute open-ended ranges. For example, if you
have data values from 0 to 10, but most are between 4 and 6, you could
specify levels as numpy.arange(4, 6.01, 0.1) and use extend='both'. Then
all values greater than 6 would get a color at one end, and all values
less than 4 would get another color at the other end. If you use a
colorbar, it will see the extend argument that was used in contourf, and
draw the colorbar with pointed ends to indicate anything over and
anything under. As illustrated above.
Eric
From the documentation I gather that I should use the norm and extend
keyword arguments, but I wasn't really able to figure out what values
I have to pass and how the matplotlib.colors.Normalize instance works.
Thanks,
-Nikolaus
--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users