I forgot "reply to all".
--- Begin Message ---
Evan,
The solution you are proposing below sounds wrong to me--I am concerned
that your color bar is not corresponding to the actual levels you are
plotting on both plots. I think that what you actually need is closer
to the attached script.
Eric
Evan Mason wrote:
Hi Eric, just further to what I said, you can see those white areas in
the stripped down version by using
a = arange(12, 23, .5)
b = arange(17, 27, .5)
and then running as before...
-Evan
On 3/27/07, *Evan Mason* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Thanks, Eric,
Yes, that works for the stripped down version, but not for what I am
trying to do. The examples I have given have the range of one of
the plots nicely fitting inside that of the other (ie, plot 1 range
15 to 26, plot 2 range 17 to 23), but sometimes with what I am doing
I have, for example, plot 1 range 15 to 23 and plot 2 range 17 to
25. In this case, passing the levels from plot 1 to plot 2 means
that levels 24 and 25 of plot 2 are stripped away; this, at least,
is what I think is happening because I have white areas of my plot
that weren't there before. It seems to me that it would be quite
useful to have the option to override the colorbar range, setting it
to be the same as defined by clim, or some other values.
As a solution for now, I think I will just use one colorbar for the
two plots. Thanks for your help with this, and the tip about being
explicit in my programs!
-Evan
import pylab as P
from matplotlib.transforms import Value, Interval
from matplotlib.ticker import MaxNLocator
N = 12 # target number of contour levels
a = P.arange(12, 23, .5)
b = P.arange(17, 27, .5)
x, y = P.meshgrid(a, b)
# get max and min for clim
cmin = min(x.min(), y.min()) # cmin = 12
cmax = max(x.max(), y.max()) # cmax = 26.5
# The following needs some convenience methods to make it easier;
# but for now, this is how you can automatically generate reasonable
# contour levels based on an overall range.
# The alternative is to manually specify the levels, e.g.,
# levels = range(int(cmin), int(cmax+1.0), 2)
intv = Interval(Value(cmin), Value(cmax))
locator = MaxNLocator(N+1)
locator.set_view_interval(intv)
locator.set_data_interval(intv)
levels = locator()
P.figure(1)
CS1 = P.contourf(x, levels=levels)
#clim(cmin, cmax)
P.colorbar(CS1)
P.figure(2)
CS2 = P.contourf(y, levels=levels)
#clim(cmin, cmax)
P.colorbar(CS2)
P.show()
--- End Message ---
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users