Revision: 4605
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4605&view=rev
Author:   jswhit
Date:     2007-12-04 18:31:36 -0800 (Tue, 04 Dec 2007)

Log Message:
-----------
better way to handle backwards compatibility in axes.get_position()

Modified Paths:
--------------
    trunk/toolkits/basemap/examples/contour_demo.py
    trunk/toolkits/basemap/examples/panelplot.py
    trunk/toolkits/basemap/examples/plotmap.py
    trunk/toolkits/basemap/examples/plotmap_masked.py
    trunk/toolkits/basemap/examples/plotmap_oo.py
    trunk/toolkits/basemap/examples/plotprecip.py
    trunk/toolkits/basemap/examples/pnganim.py
    trunk/toolkits/basemap/examples/simpletest_oo.py
    trunk/toolkits/basemap/examples/test.py

Modified: trunk/toolkits/basemap/examples/contour_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/contour_demo.py     2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/contour_demo.py     2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -21,10 +21,12 @@
 x, y = m(lons, lats)
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# setup colorbar axes instance.
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
 colorbar(drawedges=True, cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -49,10 +51,8 @@
 x, y = m(lons, lats)
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
 colorbar(drawedges=True, cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -77,10 +77,8 @@
 x, y = m(lons, lats)
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
 colorbar(drawedges=True, cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -105,10 +103,8 @@
 x, y = m(lons, lats)
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
 colorbar(drawedges=True, cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -134,10 +130,8 @@
 x, y = m(lons, lats)
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
 colorbar(drawedges=True, cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again

Modified: trunk/toolkits/basemap/examples/panelplot.py
===================================================================
--- trunk/toolkits/basemap/examples/panelplot.py        2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/panelplot.py        2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -27,10 +27,8 @@
 CS = mnh.contour(xnh,ynh,hgt,15,linewidths=0.5,colors='k')
 CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.Spectral)
 # colorbar on bottom.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = P.axes([l, b-0.05, w, 0.025]) # setup colorbar axes
 P.colorbar(cax=cax, orientation='horizontal',ticks=CS.levels[0::4]) # draw 
colorbar
 P.axes(ax)  # make the original axes current again
@@ -52,11 +50,8 @@
 CS = msh.contour(xsh,ysh,hgt,15,linewidths=0.5,colors='k')
 CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.Spectral)
 # colorbar on bottom.
-ax.apply_aspect()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = P.axes([l, b-0.05, w, 0.025]) # setup colorbar axes
 P.colorbar(cax=cax,orientation='horizontal',ticks=MultipleLocator(320)) # draw 
colorbar
 P.axes(ax)  # make the original axes current again
@@ -78,10 +73,8 @@
 CS = mnh.contour(xnh,ynh,hgt,15,linewidths=0.5,colors='k')
 CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.RdBu)
 # colorbar on right
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = P.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
 P.colorbar(cax=cax, ticks=MultipleLocator(160), format='%4i') # draw colorbar
 P.axes(ax)  # make the original axes current again
@@ -95,10 +88,8 @@
 CS = msh.contour(xsh,ysh,hgt,15,linewidths=0.5,colors='k')
 CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.RdBu)
 # colorbar on right.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = P.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
 P.colorbar(cax=cax, ticks=MultipleLocator(160), format='%4i') # draw colorbar
 P.axes(ax)  # make the original axes current again

Modified: trunk/toolkits/basemap/examples/plotmap.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap.py  2007-12-04 21:53:43 UTC (rev 
4604)
+++ trunk/toolkits/basemap/examples/plotmap.py  2007-12-05 02:31:36 UTC (rev 
4605)
@@ -32,10 +32,11 @@
 # plot image over map with imshow.
 im = m.imshow(topodat,cm.jet)
 # setup colorbar axes instance.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h])
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again

Modified: trunk/toolkits/basemap/examples/plotmap_masked.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_masked.py   2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py   2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -40,10 +40,11 @@
 # plot image over map with imshow.
 im = 
m.imshow(topodatm,palette,norm=colors.normalize(vmin=0.0,vmax=3000.0,clip=False))
 # setup colorbar axes instance.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h])
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again

Modified: trunk/toolkits/basemap/examples/plotmap_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_oo.py       2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py       2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -44,10 +44,12 @@
 topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
 # plot image over map with imshow.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# setup colorbar axes instance.
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = fig.add_axes([l+w+0.075, b, 0.05, h],frameon=False) # setup colorbar axes
 fig.colorbar(im, cax=cax) # draw colorbar
 # plot blue dot on boulder, colorado and label it as such.

Modified: trunk/toolkits/basemap/examples/plotprecip.py
===================================================================
--- trunk/toolkits/basemap/examples/plotprecip.py       2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/plotprecip.py       2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -51,10 +51,8 @@
 clevs = 
[0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150,200,250,300,400,500,600,750]
 cs = m.contourf(x,y,data,clevs,cmap=cm.s3pcpn)
 # new axis for colorbar.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = pylab.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
 # draw colorbar.
 pylab.colorbar(cs, cax, format='%g', ticks=clevs, drawedges=False) 
@@ -79,10 +77,8 @@
 im2 = copy.copy(im)
 im2.set_cmap(cm.s3pcpn_l)
 # new axis for colorbar.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = pylab.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
 # using im2, not im (hack to prevent colors from being
 # too compressed at the low end on the colorbar - results

Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py  2007-12-04 21:53:43 UTC (rev 
4604)
+++ trunk/toolkits/basemap/examples/pnganim.py  2007-12-05 02:31:36 UTC (rev 
4605)
@@ -8,34 +8,8 @@
 import pylab
 from numpy import ma
 import datetime, sys, time, subprocess
-from matplotlib.toolkits.basemap import Basemap, shiftgrid, NetCDFFile
+from matplotlib.toolkits.basemap import Basemap, shiftgrid, NetCDFFile, 
num2date
 
-hrsgregstart = 13865688 # hrs from 00010101 to 15821015 in Julian calendar.
-# times in many datasets use mixed Gregorian/Julian calendar, datetime 
-# module uses a proleptic Gregorian calendar. So, I use datetime to compute
-# hours since start of Greg. calendar (15821015) and add this constant to
-# get hours since 1-Jan-0001 in the mixed Gregorian/Julian calendar.
-gregstart = datetime.datetime(1582,10,15) # datetime.datetime instance
-
-def dateto_hrs_since_day1CE(curdate):
-    """given datetime.datetime instance, compute hours since 1-Jan-0001"""
-    if curdate < gregstart:
-        msg = 'date must be after start of gregorian calendar (15821015)!'
-        raise ValueError, msg
-    difftime = curdate-gregstart
-    hrsdiff = 24*difftime.days + difftime.seconds/3600
-    return hrsdiff+hrsgregstart
-
-def hrs_since_day1CE_todate(hrs):
-    """return datetime.datetime instance given hours since 1-Jan-0001"""
-    if hrs < 0.0:
-        msg = "hrs must be positive!"
-        raise ValueError, msg
-    delta = datetime.timedelta(hours=1)
-    hrs_sincegreg = hrs - hrsgregstart
-    curdate = gregstart + hrs_sincegreg*delta
-    return curdate
-
 # times for March 1993 'storm of the century'
 YYYYMMDDHH1 = '1993031000'
 YYYYMMDDHH2 = '1993031700'
@@ -65,13 +39,11 @@
 print datav.variables.keys()
 latitudes = data.variables['lat'][:]
 longitudes = data.variables['lon'][:].tolist()
-times = data.variables['time'][:]
+times = data.variables['time']
+# convert numeric time values to datetime objects.
+fdates = num2date(times[:],times.units)
 # put times in YYYYMMDDHH format.
-dates=[]
-for t in times:
-    t = t*24
-    fdate = hrs_since_day1CE_todate(int(t))
-    dates.append(fdate.strftime('%Y%m%d%H'))
+dates = [fdate.strftime('%Y%m%d%H') for fdate in fdates]
 if YYYYMMDDHH1 not in dates or YYYYMMDDHH2 not in dates:
     raise ValueError, 'date1 or date2 not a valid date (must be in form 
YYYYMMDDHH, where HH is 00,06,12 or 18)'
 # find indices bounding desired times.
@@ -126,10 +98,8 @@
 meridians = numpy.arange(0.,360.,20.)
 # number of repeated frames at beginning and end is n1.
 nframe = 0; n1 = 10
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 # loop over times, make contour plots, draw coastlines, 
 # parallels, meridians and title.
 for nt,date in enumerate(datelabels[1:]):

Modified: trunk/toolkits/basemap/examples/simpletest_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/simpletest_oo.py    2007-12-04 21:53:43 UTC 
(rev 4604)
+++ trunk/toolkits/basemap/examples/simpletest_oo.py    2007-12-05 02:31:36 UTC 
(rev 4605)
@@ -37,10 +37,11 @@
 # add a title.
 ax.set_title('Robinson Projection')
 # add a colorbar.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = fig.add_axes([l, b-0.1, w, 0.03],frameon=False) # setup colorbar axes
 fig.colorbar(cs, cax=cax, orientation='horizontal',ticks=cs.levels[::3]) 
 # save image (width 800 pixels with dpi=100 and fig width 8 inches).

Modified: trunk/toolkits/basemap/examples/test.py
===================================================================
--- trunk/toolkits/basemap/examples/test.py     2007-12-04 21:53:43 UTC (rev 
4604)
+++ trunk/toolkits/basemap/examples/test.py     2007-12-05 02:31:36 UTC (rev 
4605)
@@ -29,10 +29,12 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topoin,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+# get axes position, add colorbar axes to right of this.
+# for matplotlib 0.91 and earlier, could do l,b,w,h = ax.get_position()
+# for post 0.91, pos = ax.get_position(); l,b,w,h = pos.bounds
+# this works for both.
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -111,10 +113,8 @@
 im = m.imshow(topodat,cm.jet)
 # get current axis instance.
 ax = gca()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -145,10 +145,8 @@
 im = m.imshow(topodat,cm.jet)
 # get current axis instance.
 ax = gca()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -180,10 +178,8 @@
 im = m.imshow(topodat,cm.jet)
 # get current axis instance.
 ax = gca()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -214,10 +210,8 @@
 im = m.imshow(topodat,cm.jet)
 # get current axis instance.
 ax = gca()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -250,10 +244,8 @@
 im = m.imshow(topodat,cm.jet)
 # get current axis instance.
 ax = gca()
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -283,10 +275,8 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -318,10 +308,8 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -355,10 +343,8 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 im.set_clim(-4000.,3000.) # adjust range of colors.
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -392,10 +378,8 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -425,10 +409,8 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -459,10 +441,8 @@
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -502,10 +482,8 @@
 #  and values outside projection limb would be handled transparently
 #  - see contour_demo.py)
 im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -545,10 +523,8 @@
 #  and values outside projection limb would be handled transparently
 #  - see contour_demo.py)
 im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -575,10 +551,8 @@
 # plot image over map with pcolormesh.
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -604,10 +578,8 @@
 # plot image over map with pcolormesh.
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again
@@ -633,10 +605,8 @@
 # plot image over map with pcolormesh.
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
-try: 
-    l,b,w,h = ax.get_position()
-except:
-    l,b,w,h = (ax.get_position()).bounds
+pos = ax.get_position()
+l, b, w, h = getattr(pos, 'bounds', pos)
 cax = axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes.
 colorbar(cax=cax) # draw colorbar
 axes(ax)  # make the original axes current again


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to