problem with colorbar of contour

Hello,
I have a contour with a clim smaller than the limits of my data... and because of this there is an error when I try to add a colorbar.
Can someone help?
Thanks
MMA

eg:

x=arange(20)
y=arange(30)
x,y=meshgrid(x,y)
v=sqrt(x+y) # max=6.928, min=0.0

# next is ok
figure()
contour(x,y,v)
clim(0,7)
colorbar()

# next gives the error: "ValueError: levels are outside colorbar range"
figure()
contour(x,y,v)
clim(2,6)
colorbar()

Martinho MA wrote:

Hello,
I have a contour with a clim smaller than the limits of my data... and because of this there is an error when I try to add a colorbar.
Can someone help?
Thanks
MMA

I think the basic problem is that you are trying to use a colorbar as a legend in a case where it doesn't really makes sense; the colorbar is mapping a range of values to a range of colors, and you have values that are outside that range. There are a couple ways to fix the problem:

1) Try using "colorbar(extend='both')". This is a workaround, but it may do what you want.

2) Explicitly specify a list of contour levels that are within the range of your clim. This is a better solution.

Eric

ยทยทยท

eg:

x=arange(20)
y=arange(30)
x,y=meshgrid(x,y)
v=sqrt(x+y) # max=6.928, min=0.0

# next is ok
figure()
contour(x,y,v)
clim(0,7)
colorbar()

# next gives the error: "ValueError: levels are outside colorbar range"
figure()
contour(x,y,v)
clim(2,6)
colorbar()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users