What you need is to adjust the axes position of the colorbar at the
drawing time (because the axes position of the contour plot is
adjusted only during the drawing time).
You may do this by properly setting the axe_locator property of the axes.

If you're using mpl 0.99, axes_grid toolkit may be helpful.
I just posted a simple example with the screenshot in the link below.

http://abitofpythonabitofastronomy.blogspot.com/2009/08/creating-color-bar-using-inset-axes.html

Regards,

-JJ



On Sat, Aug 22, 2009 at 9:51 PM, Patrick Marsh<patrickmars...@gmail.com> wrote:
> Greeting MPL world,
>
> I have a contourf plot where the aspect ratio is 1.  I need to add a
> colorbar to the plot in a manner that keeps the colorbar in the same
> place relative to the contourf plot (good.png), even if the parent
> window is resized.  I can do this with text, but haven't been able to
> figure out how to do it with a colorbar.  To the best of my knowledge,
> there are two ways forward.
>
> 1.)  I can create an entirely new axis instance (cax) but will need to
> find a way to define the axes in a relative way to the original ax
> instance.  As it stands now, I can only define axes in terms of the
> total figure size.  As a result, the figure looks like it does in
> bad.png
>
>
> 2.)  I can use the original ax instance, but need to find a way to
> have more control over the colorbar placement.  For example, it needs
> to "sit" on the x-axis and not be centered in the middle of the yaxis.
>  Using shrink and aspect, I can get the plot size to be correct,
> however it's position is centered on the yaxis as in bad2.png
>
> Is there a way to accomplish what I'm needing to do and I'm just missing it?
>
> Thanks in advance,
> Patrick
> ---
> Patrick MarshC
> Graduate Research Assistant
> School of Meteorology
> University of OklahomaC
> http://www.patricktmarsh.com
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to