Skip to content

Commit 140ebab

Browse files
author
Jeffrey Whitaker
committed
use fractional width for pad colorbar keyword
1 parent 838175b commit 140ebab

File tree

6 files changed

+17
-24
lines changed

6 files changed

+17
-24
lines changed

doc/users/figures/make.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#mplshell = IPython.Shell.MatplotlibShell('mpl') # for Ipython 0.10
1010
mplshell = IPython.core.interactiveshell.InteractiveShell() # for Ipython 0.11
1111

12-
formats = [('png', 100),
13-
('hires.png', 200),
14-
('pdf', 72)]
12+
#formats = [('png', 100),
13+
# ('hires.png', 200),
14+
# ('pdf', 72)]
15+
formats = [('png', 100)]
1516

1617
def figs():
1718
print 'making figs'

doc/users/figures/plotetopo5.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@
3939
m.drawparallels(parallels,labels=[1,0,0,1])
4040
meridians = np.arange(10.,360.,30.)
4141
m.drawmeridians(meridians,labels=[1,0,0,1])
42-
# use axes_grid toolkit to make colorbar axes.
43-
divider = make_axes_locatable(ax)
44-
cax = divider.append_axes("right", size="5%", pad=0.1)
45-
cb = fig.colorbar(im,cax=cax)
42+
# add colorbar
43+
cb = m.colorbar(im,"right", size="5%", pad='2%')
4644
ax.set_title('ETOPO5 Topography - Lambert Conformal Conic')
4745
fig.savefig('etopo5.png')
4846

doc/users/figures/plotprecip.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150,200,250,300,400,500,600,750]
4343
cs = m.contourf(x,y,data,clevs,cmap=cm.s3pcpn)
4444
# add colorbar.
45-
cbar = m.colorbar(cs,location='bottom',pad=0.25)
45+
cbar = m.colorbar(cs,location='bottom',pad="5%")
4646
cbar.set_label('mm')
4747
# add title
4848
plt.title(prcpvar.long_name+' for period ending '+prcpvar.dateofdata)
4949
plt.savefig('plotprecip.png')
50-
plt.show()

doc/users/figures/plotsst.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@
4848
# draw parallels and meridians, but don't bother labelling them.
4949
m.drawparallels(np.arange(-90.,120.,30.))
5050
m.drawmeridians(np.arange(0.,420.,60.))
51-
# use axes_grid toolkit to make colorbar axes.
52-
divider = make_axes_locatable(ax)
53-
cax = divider.append_axes("bottom", size="5%", pad=0.1)
54-
cb = plt.colorbar(im1,orientation='horizontal',cax=cax)
51+
# add colorbar
52+
cb = m.colorbar(im1,"bottom", size="5%", pad="2%")
5553
# add a title.
5654
ax.set_title('SST and ICE analysis for %s'%date)
5755
plt.savefig('plotsst.png')

doc/users/figures/plotwindvec.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@
6464
m.drawcoastlines(linewidth=1.5)
6565
m.drawparallels(parallels)
6666
m.drawmeridians(meridians)
67-
# use axes_grid toolkit to make colorbar axes.
68-
divider = make_axes_locatable(ax)
69-
cax = divider.append_axes("bottom", size="5%", pad=0.1)
70-
cb = plt.colorbar(CS2,orientation='horizontal',cax=cax)
67+
# add colorbar
68+
cb = m.colorbar(CS2,"bottom", size="5%", pad="2%")
7169
cb.set_label('hPa')
7270
# set plot title
7371
ax.set_title('SLP and Wind Vectors '+str(date))
@@ -85,10 +83,8 @@
8583
m.drawcoastlines(linewidth=1.5)
8684
m.drawparallels(parallels)
8785
m.drawmeridians(meridians)
88-
# use axes_grid toolkit to make colorbar axes.
89-
divider = make_axes_locatable(ax)
90-
cax = divider.append_axes("bottom", size="5%", pad=0.1)
91-
cb = plt.colorbar(CS2,orientation='horizontal',cax=cax)
86+
# add colorbar
87+
cb = m.colorbar(CS2,"bottom", size="5%", pad="2%")
9288
cb.set_label('hPa')
9389
# set plot title.
9490
ax.set_title('SLP and Wind Barbs '+str(date))

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,13 +3671,14 @@ def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
36713671
rets = [ret.set_zorder(zorder) for ret in rets]
36723672
return rets
36733673

3674-
def colorbar(self,mappable=None,location='right',size="5%",pad=0.1,fig=None,ax=None,**kwargs):
3674+
def colorbar(self,mappable=None,location='right',size="5%",pad='2%',fig=None,ax=None,**kwargs):
36753675
"""
36763676
Add colorbar to axes associated with a map.
36773677
The colorbar axes instance is created using the axes_grid toolkit.
36783678
36793679
.. tabularcolumns:: |l|L|
36803680
3681+
============== ====================================================
36813682
Keywords Description
36823683
============== ====================================================
36833684
mappable the Image, ContourSet, etc. to which the colorbar
@@ -3686,10 +3687,10 @@ def colorbar(self,mappable=None,location='right',size="5%",pad=0.1,fig=None,ax=N
36863687
location where to put colorbar ('top','bottom','left','right')
36873688
Default 'right'.
36883689
size width of colorbar axes (string 'N%', where N is
3689-
an integer describing the percentage of the parent
3690+
an integer describing the fractional width of the parent
36903691
axes). Default '5%'.
36913692
pad Padding between parent axes and colorbar axes in
3692-
inches. Default 0.1.
3693+
same units as size. Default '2%'.
36933694
fig Figure instance the map axes instance is associated
36943695
with. Default None, and matplotlib.pyplot.gcf() is used
36953696
to retrieve the current active figure instance.

0 commit comments

Comments
 (0)