colorbar() fix limit on Heat map

Hi All,

You may remember from my previous post I was having problems plotting a
heatmap, however Pete came through for me and made it work.

Anyway, I have almost finished what I want to do. The only issue is fixing
the colorbar() range limit.

Sometimes the my values are 0.01 to 0.2 for example, and other times there
0.01 to 0.99.

So what happens it the colorbar() automagically adjusts the gradient
according to my values, however I do not want it to do that, I want the
graph to be consistantly 0 - 1 (blue - red).

I have tried things like colorbar(0,1), however no luck.

If you could let me know how to fix the range, I would be very grateful.

Regards

···

--
View this message in context: http://www.nabble.com/colorbar()-fix-limit-on-Heat-map-tp18923300p18923300.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

stuartornum wrote:

Hi All,

You may remember from my previous post I was having problems plotting a
heatmap, however Pete came through for me and made it work.

Anyway, I have almost finished what I want to do. The only issue is fixing
the colorbar() range limit.

Sometimes the my values are 0.01 to 0.2 for example, and other times there
0.01 to 0.99.

So what happens it the colorbar() automagically adjusts the gradient
according to my values, however I do not want it to do that, I want the
graph to be consistantly 0 - 1 (blue - red).

I have tried things like colorbar(0,1), however no luck.

If you could let me know how to fix the range, I would be very grateful.

Regards
  

Stuart: Use the vmin/vmax keyword arguments if your are using imshow or pcolor/pcolormesh. If you are using contourf, just specify the contour levels to span the range 0-1 (i.e. clevs=linspace(-1,1,15)).

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Jeff,

That worked perfectly ! Thank you.

One more question... how would I change the colour scheme of the colorbar()?

Thanks again

···

--
View this message in context: http://www.nabble.com/colorbar()-fix-limit-on-Heat-map-tp18923300p18925645.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

stuartornum wrote:

Jeff,

That worked perfectly ! Thank you.

One more question... how would I change the colour scheme of the colorbar()?

Thanks again
  

Stuart: Use the cmap argument to specify a color map.

Have you checked out the pylab examples? For me, they are the best way to learn how to use matplotlib effectively.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

In particular:

johnh@...1653...:examples> find . -name "*.py"|xargs grep -il colorbar
./animation/dynamic_image_wxagg2.py
./tests/backend_driver.py
./pylab_examples/multi_image.py
./pylab_examples/contourf_demo.py
./pylab_examples/contourf_log.py
./pylab_examples/subplots_adjust.py
./pylab_examples/contour_image.py
./pylab_examples/contour_demo.py
./pylab_examples/pcolor_demo.py
./pylab_examples/image_masked.py
./pylab_examples/poormans_contour.py
./pylab_examples/hexbin_demo.py
./pylab_examples/line_collection2.py
./pylab_examples/pcolor_log.py
./pylab_examples/scatter_demo2.py
./pylab_examples/griddata_demo.py
./pylab_examples/hexbin_demo2.py
./api/colorbar_only.py
./api/patch_collection.py

···

On Mon, Aug 11, 2008 at 8:31 AM, Jeff Whitaker <jswhit@...146...> wrote:

Have you checked out the pylab examples? For me, they are the best way
to learn how to use matplotlib effectively.