From: Benjamin Root <ben.root@ou.edu>
To: Michael Rawlins <rawlins02@yahoo.com>
Cc: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@lists.sourceforge.net>
Sent: Tuesday, January 17, 2012 10:36 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command


On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins <rawlins02@yahoo.com> wrote:

I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The code below, placed in a file and executed with python, draws 4 maps using basemap. I've been unable to get a colorbar to show up anywhere on the figure. Ideally I would like the option of placing a colorbar across the bottom, spanning across both bottom map panels.  Also would need the option of placing a colorbar either to the right of or below each map. Uncommenting the two lines under "Here make a colorbar" cause an error. I've used those commands when creating just one map using the figure command.

TIA,
Mike



Mike,

Try using the axes_grid1 toolkit to produce your axes objects and to allocate enough room for colorbars.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html

Cheers!
Ben Root

P.S. - a little history, there used to be an axes_grid toolkit, but has since been superseded by axes_grid1.


Clicking on source code on that page produces an error. For several of the graphic on that page, dropping the code into a file and running also produces various errors. Being new to this software, having a specific example that I can run and then incorporate into my code would be a big help.

Mike