contourf with preassigned range

Hello experts,

I have two matrices (one random matrix with entries between -3 and +3 and one with entries say between -4 and 4).

I would like to plot a contourf for both of them with corresponding color scheme (ranging say from -5 to 5).

I am a newbie, so please apologize the rather low level of this question.

cheers

Thomas

Thomas Schmelzer wrote:

Hello experts,
I have two matrices (one random matrix with entries between -3 and +3 and one with entries say between -4 and 4).
I would like to plot a contourf for both of them with corresponding color scheme (ranging say from -5 to 5).
I am a newbie, so please apologize the rather low level of this question.
cheers
Thomas

The simplest way is to use the same array of contour levels for both. Here is a simplest-possible code fragment to illustrate:

from pylab import *
F = 6 * (rand(20,20) - 0.5)
G = 8 * (rand(20,20) - 0.5)
clevs = arange(-5,6)
subplot(2,1,1)
contourf(F, clevs)
colorbar()
subplot(2,1,2)
contourf(G, clevs)
colorbar()
show()

For additional information:
1) In the matplotlib examples directory, look for all the examples that use contourf.
2) Look at the contourf (and other) docstrings.

If you are not already using ipython, get it and try it--it makes the experimentation and learning much easier.

Eric