colorbar() moves to wrong place on subplots_adjust call

I've been seeing weird behaviour with using a colorbar() and adjusting
the plot extents, either interactively in the GUI or through
figure.subplots_adjust. If I adjust the axes after drawing the
colorbar, it is placed incorrectly. This seems to happen independently
of the backends that I have and even continues through to the written
file with figure.save_fig. I'm using matplotlib.__version__ = 1.1.0,
with a git checkout that I recently updated.

I have included a short test .py that shows the problem, and two
images that it produces:
- Adjusting after drawing the plot: http://ndevenish.com/images/post_adjust.png
- Adjusting before drawing the plot: http://ndevenish.com/images/pre_adjust.png

Is there a way I can avoid or correct this behaviour? It certainly
seems erroneous that using the figure GUI to adjust plot bounds
doesn't work, and is an especially nice way of tweaking for final
plots.

Thanks,

Nick

(apologies if this comes through twice, gmail was acting up)

example.py (703 Bytes)

Unfortunately no.
This is a limitation of how colobar is currently implemented (v1.1
will have a workaround to this).
I think the simple (but may not be good enough) workaround is to call
"colorbar" after subplot adjusting is done.

Alternatively, you may try the axes_grid1 toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#colorbar-whose-height-or-width-in-sync-with-the-master-axes

Regards,

-JJ

ยทยทยท

On Tue, Jun 14, 2011 at 4:58 AM, Nicholas Devenish <misnomer+matplotlib@...287...> wrote:

Is there a way I can avoid or correct this behaviour? It certainly
seems erroneous that using the figure GUI to adjust plot bounds
doesn't work, and is an especially nice way of tweaking for final
plots.