question about levels & colormaps for contour functions

Hi,

I would like to know how I can pass an array of levels and also a colormap to the contour() function and have the levels span the entire colormap. example...

if I do the following....

Lv=(1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75)

cs=plt.contourf(X,Y,waveheight,Lv,cmap=cm.jet,extend='both')

I would expect that contours that are in the higher levels (i.e., levels above value '14' in my levels array) would be plotted with lighter colors in the cm.jet spectrum; the greens, yellows,oranges,reds, etc.

However, contourf is simply breaking up the lower,"dark blue" half of the cm.jet spectrum into small slices, and spreading all of my levels throughout only the bottom half of cm.jet.

I followed this tutorial:
http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations

that shows how to create a "discrete" colormap, but this also didnt work; the contourf function again simply sliced up the lower, blue colors and spread my all of my layers across the "blues" in my discrete colormap.

If I use a colors array instead of a colormap, I can achieve what I want. However, Id like to be able to use a colormap so that I dont have to manually create color arrays everytime that I want to change my colorscheme.

So, how can I force contour() to spread my levels across THE WHOLE spectrum of a colormap?

Please help,

Thanks,
P.Romero

···

_________________________________________________________________
Express your personality in color! Preview and select themes for Hotmail®.
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme

Pablo Romero wrote:

Hi,
I would like to know how I can pass an array of levels and also a colormap to the contour() function and have the levels span the entire colormap. example...
if I do the following....

Lv=(1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75)
cs=plt.contourf(X,Y,waveheight,Lv,cmap=cm.jet,extend='both')

However, contourf is simply breaking up the lower,"dark blue" half of the cm.jet spectrum into small slices, and spreading all of my levels throughout only the bottom half of cm.jet.

I don't see the problem yet. Here is an attempt to recreate what it sounds like you are describing above (run in ipython -pylab):

contourf(rand(10,12), arange(0,5.01,0.2), cmap=cm.jet, extend='both')
colorbar()

The data are all blue because they are in the 0-1 range, while the levels span the 0-5 range. The colorbar shows that the colormap is covering the latter range, as it should.

If you can make a simple self-contained example like this, and then describe the difference between what it does and what you want it to do, we can figure out how to get your desired result.

Eric

···

I followed this tutorial:
http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations
that shows how to create a "discrete" colormap, but this also didnt work; the contourf function again simply sliced up the lower, blue colors and spread my all of my layers across the "blues" in my discrete colormap.

So, how can I force contour() to spread my levels across THE WHOLE spectrum of a colormap?
Please help,
Thanks,
P.Romero

Express your personality in color! Preview and select themes for Hotmail®. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I find you?
Paola

···

Pablo Romero-2 wrote:

Hi,
I would like to know how I can pass an array of levels and also a colormap to the contour() function and have the levels span the entire colormap. example…
if I do the following…
Lv=(1,3,5,6,7,8,9,10,12,14,16,18,20,25,30,35,40,50,75)
cs=plt.contourf(X,Y,waveheight,Lv,cmap=cm.jet,extend=‘both’)
I would expect that contours that are in the higher levels (i.e., levels above value ‘14’ in my levels array) would be plotted with lighter colors in the cm.jet spectrum; the greens, yellows,oranges,reds, etc. However, contourf is simply breaking up the lower,“dark blue” half of the cm.jet spectrum into small slices, and spreading all of my levels throughout only the bottom half of cm.jet.
I followed this tutorial:
http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations
that shows how to create a “discrete” colormap, but this also didnt work; the contourf function again simply sliced up the lower, blue colors and spread my all of my layers across the “blues” in my discrete colormap.
If I use a colors array instead of a colormap, I can achieve what I want. However, Id like to be able to use a colormap so that I dont have to manually create color arrays everytime that I want to change my colorscheme.
So, how can I force contour() to spread my levels across THE WHOLE spectrum of a colormap?
Please help,
Thanks,
P.Romero


Express your personality in color! Preview and select themes for Hotmail®. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme

Apps built with the Adobe® Flex® framework and Flex Builder™ are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse™based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


View this message in context: Re: question about levels & colormaps for contour functions

Sent from the matplotlib - users mailing list archive at Nabble.com.