Highlight values outside colorbar limits

Hi,

Is it possible to color values outside the colorbar limits in a different color than the colorbar itself. So for example, an otherwise greyscale plot could have the values outside the upperlimit in blue and those below the lower limit in red, so that these points are not confused with the legitimate data points (as they can be when they are just more black and white points as default).

Thanks,
James McMurray

Okay, so using cm.set_over() and set_under works, but is there any way of adding the set colors to the edges of the colorbar?

···

On 29 August 2011 15:47, James McMurray <jamesmcm03@…287…> wrote:

Hi,

Is it possible to color values outside the colorbar limits in a different color than the colorbar itself. So for example, an otherwise greyscale plot could have the values outside the upperlimit in blue and those below the lower limit in red, so that these points are not confused with the legitimate data points (as they can be when they are just more black and white points as default).

Thanks,
James McMurray

This example should do what you want:

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

I hope that helps!
Ben Root

···

On Mon, Aug 29, 2011 at 9:59 AM, James McMurray <jamesmcm03@…878…287…> wrote:

Okay, so using cm.set_over() and set_under works, but is there any way of adding the set colors to the edges of the colorbar?

    Okay, so using cm.set_over() and set_under works, but is there any
    way of adding the set colors to the edges of the colorbar?

This example should do what you want:

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

Also http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html.

Note that "extend=both" is the relevant kwarg. With contourf, the kwarg goes in the contourf call, and colorbar automatically gets it from the ContourSet. With other types of color mappable plot, the kwarg needs to be given directly to the colorbar call.

Eric

···

On 08/29/2011 05:44 AM, Benjamin Root wrote:

On Mon, Aug 29, 2011 at 9:59 AM, James McMurray <jamesmcm03@...287... > <mailto:jamesmcm03@…287…>> wrote:

I hope that helps!
Ben Root

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Crap! Is that why my colorbars from my pcolors (or was it pcolormesh?) never worked right? I have been making colorbars directly for a while now because I couldn’t figure out why those colorbars didn’t work right.

I think I will file a feature request to fix this inconsistency. Probably will be a bit involved to fix it, though.

Ben Root

···

On Mon, Aug 29, 2011 at 12:30 PM, Eric Firing <efiring@…878…202…> wrote:

On 08/29/2011 05:44 AM, Benjamin Root wrote:

On Mon, Aug 29, 2011 at 9:59 AM, James McMurray <jamesmcm03@…287… > > mailto:jamesmcm03@...287...> wrote:

Okay, so using cm.set_over() and set_under works, but is there any
way of adding the set colors to the edges of the colorbar?

This example should do what you want:

http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

Also

http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html.

Note that “extend=both” is the relevant kwarg. With contourf, the kwarg

goes in the contourf call, and colorbar automatically gets it from the

ContourSet. With other types of color mappable plot, the kwarg needs to

be given directly to the colorbar call.

Eric

     >
     > Okay, so using cm.set_over() and set_under works, but is
    there any
     > way of adding the set colors to the edges of the colorbar?
     >
     > This example should do what you want:
     >
     > http://matplotlib.sourceforge.net/examples/api/colorbar_only.html

    Also
    http://matplotlib.sourceforge.net/examples/pylab_examples/contourf_demo.html.

    Note that "extend=both" is the relevant kwarg. With contourf, the kwarg
    goes in the contourf call, and colorbar automatically gets it from the
    ContourSet. With other types of color mappable plot, the kwarg needs to
    be given directly to the colorbar call.

    Eric

Crap! Is that why my colorbars from my pcolors (or was it pcolormesh?)
never worked right? I have been making colorbars directly for a while
now because I couldn't figure out why those colorbars didn't work right.

I think I will file a feature request to fix this inconsistency.
Probably will be a bit involved to fix it, though.

It's not entirely an inconsistency. The logic is this: extend='both' (or whatever) directly affects the levels used in contourf; there is nothing similar in imshow or pcolor*. Adding the extend kwarg to them would simply be putting it in place for later use by colorbar.

Eric

···

On 08/29/2011 07:40 AM, Benjamin Root wrote:

On Mon, Aug 29, 2011 at 12:30 PM, Eric Firing <efiring@...202... > <mailto:efiring@…202…>> wrote:
    On 08/29/2011 05:44 AM, Benjamin Root wrote:
     > On Mon, Aug 29, 2011 at 9:59 AM, James McMurray > <jamesmcm03@...287... <mailto:jamesmcm03@…287…> > > <mailto:jamesmcm03@…287…>> wrote:

Ben Root

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options