On Thu, Oct 14, 2010 at 7:58 AM, Jeff Whitaker <jsw...@fastmail.fm> wrote:

>   On 10/14/10 5:21 AM, Bala subramanian wrote:
> > Friends,
> > I wrote a small program to plot a matrix using contourf function. The
> > code is pasted below. The image that is created is attached (1.png).
> > Now if i make the same figure, just by omitting the colorbar by
> > commenting the line, then i see that the contourf output is different
> > (2.png). Why this difference ? Whether i include colorbar or not, the
> > contourf should create similar plot right ?. Am i wrong something
> > wrong in the code. Kindly help me to understand the problem.
>
> Bala:  The shape of the plot changes, because colorbar adjusts the axes
> to make room for itself.  Otherwise the plots look identical.  Am I
> missing something?
>
> -Jeff
>
>
Jeff, Bala:

I see what is wrong... the blues and reds are missing if Bala takes out the
colorbar call.  This is because the calls to cmap.set_under() and
cmap.set_over() are being done *after* the call to contourf().  Somehow, if
colorbar() is called, then the data in the colormap gets updated for the
process of rendering the colorbar, but it does not happen otherwise.

A lot of stuff in the colormaps are designed around the idea of deferred
processing to save memory and processing time.  I am not sure if this is a
bug or not, but I would have expected that the call to show() would properly
updated the contourf data, irrespective of the call to colorbar or not.  I
would be curious to see what would happen if set_under and set_over were
called after the call to colorbar.

Bala, in case you haven't noticed yet, a proper workaround would be calling
set_under and set_over *before* calling contourf().

Ben Root
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to