|
From: Mathew Y. <mat...@gm...> - 2010-04-01 20:00:36
|
This doesn't work for what I'm doing. Unless I call "contour" or something similar, this will fail. I am only using m.plot and this doesn't set things up properly to call "colorbar". On Thu, Apr 1, 2010 at 12:40 PM, Jeff Whitaker <js...@fa...> wrote: > On 4/1/10 1:24 PM, Mathew Yeates wrote: > >> Hi >> >> I have a Basemap and I want to manually add a colorbar to the side. As you >> can see in the attached image, the colorbar is not correctly positioned. >> >> Here is a snippet of code >> >> ax=fig.add_axes([0.1,0.1,0.8,.8]) >> m = Basemap(resolution='c',projection='cyl',lon_0=0,ax=ax) >> >> cax = fig.add_axes([0.9, 0.1, 0.1, 0.8]) # setup colorbar axes. >> cmap = mpl.cm.cool >> norm = mpl.colors.Normalize(vmin=5, vmax=10) >> cb1 = mpl.colorbar.ColorbarBase(cax, cmap=cmap, >> norm=norm, >> orientation='vertical') >> >> what am I doing wrong? >> >> Mathew >> > Nothing. You just have to tweak the cax parameters to get it positioned > where you want it. > > A quick and dirty approach would be to let matplotlib position the colorbar > by using > > import matplotlib.pyplot as plt > > <plot stuff on basemap> > > plt.colorbar(orientation='vertical',shrink=0.5) # play with the shrink > param to get it to be the same size as the map > > -Jeff > > > -- > Jeffrey S. Whitaker Phone : (303)497-6313 > Meteorologist FAX : (303)497-6449 > NOAA/OAR/PSD R/PSD1 Email : Jef...@no... > 325 Broadway Office : Skaggs Research Cntr 1D-113 > Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg > > |