________________________________
 From: Benjamin Root <ben.r...@ou.edu>
To: Michael Rawlins <rawlin...@yahoo.com> 
Cc: "matplotlib-users@lists.sourceforge.net" 
<matplotlib-users@lists.sourceforge.net> 
Sent: Thursday, January 19, 2012 10:07 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 

On Thursday, January 19, 2012, Michael Rawlins <rawlin...@yahoo.com> wrote:
>
>
>
> Forum:
>
> Still unable to get a colorbar alongside the panels in this simple example.  
> One last request for assistance. Thanks.
>
> Mike
>
> import sys,getopt
> from mpl_toolkits.basemap import Basemap, shiftgrid, cm
> #from netCDF3 import Dataset as NetCDFFile
> from mpl_toolkits.basemap import  NetCDFFile
> from pylab import *
> import  matplotlib.pyplot as plt
>
> cmap = cm.get_cmap('jet', 10)    # 10 discrete colors
>
> m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
>             resolution='l',area_thresh=1000.,projection='lcc',\
>             lat_1=65.,lon_0=-73.3)
> xtxt=200000. #offset for text
> ytxt=200000.
> parallels = arange(38.,48.,2.)
> meridians = arange(-80.,-64.,2.)
>
> xsize = rcParams['figure.figsize'][0]
> fig=figure(figsize=(xsize,m.aspect*xsize))
>
> ############################################################################################
> subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.15, 
> hspace=0.11)
> # Make the first map
> plt.subplot(1,2,1)
>
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.drawcountries()
> m.drawstates()
>
> #  Here make a colorbar.
> cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
> #colorbar(format='%3.1f', ticks=[-1.5, -1.2, -0.9, -0.6, -0.3, 0.0, 0.3, 0.6, 
> 0.9, 1.2, 1.5], cax=cax)
> #colorbar(cax=cax)
>
> #  Make the second map  
> #########################################################################
> plt.subplot(1,2,2)
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.drawcountries()
> m.drawstates()
>
> plt.show()
> plt.savefig("map.eps")
> plt.clf()   # Clears the figure object
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>

I recommend upgrading to v1.1.0. There are some PPAs out there that has a more 
recent version of mpl available as a package. Or you can install from source.  
Instructions for doing that is in the FAQ.

Ben Root


Have upgraded to v1.2.x.  The example above runs fine. Ideally would like to 
place a colorbar to right of each panel or below each panel or one single 
colorbar spanning across both maps.  Pointers to specific examples or edits to 
the code much appreciated. Note: basemap is required to run the example.

Mike
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to