Revision: 4545
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4545&view=rev
Author: jswhit
Date: 2007-12-02 06:24:29 -0800 (Sun, 02 Dec 2007)
Log Message:
-----------
wrap ax.get_position in a try/except so examples will work with transforms
branch.
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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/contour_demo.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -21,7 +21,10 @@
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)
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -46,7 +49,10 @@
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)
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -71,7 +77,10 @@
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)
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -96,7 +105,10 @@
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)
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -122,7 +134,10 @@
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)
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/panelplot.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -27,7 +27,10 @@
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.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -50,7 +53,10 @@
CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.Spectral)
# colorbar on bottom.
ax.apply_aspect()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -72,7 +78,10 @@
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
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -86,7 +95,10 @@
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.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC (rev
4544)
+++ trunk/toolkits/basemap/examples/plotmap.py 2007-12-02 14:24:29 UTC (rev
4545)
@@ -32,7 +32,10 @@
# plot image over map with imshow.
im = m.imshow(topodat,cm.jet)
# setup colorbar axes instance.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -40,7 +40,10 @@
# 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.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -44,7 +44,10 @@
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)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/plotprecip.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -51,7 +51,10 @@
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.
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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)
@@ -76,7 +79,10 @@
im2 = copy.copy(im)
im2.set_cmap(cm.s3pcpn_l)
# new axis for colorbar.
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC (rev
4544)
+++ trunk/toolkits/basemap/examples/pnganim.py 2007-12-02 14:24:29 UTC (rev
4545)
@@ -126,7 +126,10 @@
meridians = numpy.arange(0.,360.,20.)
# number of repeated frames at beginning and end is n1.
nframe = 0; n1 = 10
-l,b,w,h=ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
# 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-02 13:57:34 UTC
(rev 4544)
+++ trunk/toolkits/basemap/examples/simpletest_oo.py 2007-12-02 14:24:29 UTC
(rev 4545)
@@ -37,7 +37,10 @@
# add a title.
ax.set_title('Robinson Projection')
# add a colorbar.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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-02 13:57:34 UTC (rev
4544)
+++ trunk/toolkits/basemap/examples/test.py 2007-12-02 14:24:29 UTC (rev
4545)
@@ -29,7 +29,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topoin,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -108,7 +111,10 @@
im = m.imshow(topodat,cm.jet)
# get current axis instance.
ax = gca()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -139,7 +145,10 @@
im = m.imshow(topodat,cm.jet)
# get current axis instance.
ax = gca()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -171,7 +180,10 @@
im = m.imshow(topodat,cm.jet)
# get current axis instance.
ax = gca()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -202,7 +214,10 @@
im = m.imshow(topodat,cm.jet)
# get current axis instance.
ax = gca()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -235,7 +250,10 @@
im = m.imshow(topodat,cm.jet)
# get current axis instance.
ax = gca()
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -265,7 +283,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topodat,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -297,7 +318,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topodat,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -331,7 +355,10 @@
# plot image over map.
im = m.imshow(topodat,cm.jet)
im.set_clim(-4000.,3000.) # adjust range of colors.
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -365,7 +392,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topodat,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -395,7 +425,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topodat,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -426,7 +459,10 @@
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# plot image over map.
im = m.imshow(topodat,cm.jet)
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -466,7 +502,10 @@
# and values outside projection limb would be handled transparently
# - see contour_demo.py)
im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -506,7 +545,10 @@
# and values outside projection limb would be handled transparently
# - see contour_demo.py)
im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -533,7 +575,10 @@
# plot image over map with pcolormesh.
x,y = m(*meshgrid(lonsin,latsin))
p = m.pcolormesh(x,y,topodatin,shading='flat')
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -559,7 +604,10 @@
# plot image over map with pcolormesh.
x,y = m(*meshgrid(lonsin,latsin))
p = m.pcolormesh(x,y,topodatin,shading='flat')
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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
@@ -585,7 +633,10 @@
# plot image over map with pcolormesh.
x,y = m(*meshgrid(lonsin,latsin))
p = m.pcolormesh(x,y,topodatin,shading='flat')
-l,b,w,h = ax.get_position()
+try:
+ l,b,w,h = ax.get_position()
+except:
+ l,b,w,h = (ax.get_position()).bounds
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