SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

From: <js...@us...> - 2007年11月30日 14:36:46
Revision: 4519
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4519&view=rev
Author: jswhit
Date: 2007年11月30日 06:36:43 -0800 (2007年11月30日)
Log Message:
-----------
no Float32 anymore
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/pnganim.py
 trunk/toolkits/basemap/examples/warpimage.py
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py	2007年11月30日 12:58:57 UTC (rev 4518)
+++ trunk/toolkits/basemap/examples/pnganim.py	2007年11月30日 14:36:43 UTC (rev 4519)
@@ -2,15 +2,13 @@
 # as an animation using a tool like imagemagick animate, or
 # converted to an animate gif (using imagemagick convert).
 
-# requires pydap module.
-try:
- from dap import client
-except:
- raise ImportError,"requires pyDAP module (version 2.1 or higher) from http://pydap.org"
-import pylab as p
-from matplotlib.numerix import ma
+# reads data over http - needs an active internet connection.
+
+import numpy
+import pylab
+from numpy import ma
 import datetime, sys, time, subprocess
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from matplotlib.toolkits.basemap import Basemap, shiftgrid, NetCDFFile
 
 hrsgregstart = 13865688 # hrs from 00010101 to 15821015 in Julian calendar.
 # times in many datasets use mixed Gregorian/Julian calendar, datetime 
@@ -55,19 +53,19 @@
 print URLu
 print URLv
 try:
- data = client.open(URL)
- datau = client.open(URLu)
- datav = client.open(URLv)
+ data = NetCDFFile(URL)
+ datau = NetCDFFile(URLu)
+ datav = NetCDFFile(URLv)
 except:
 raise IOError, 'opendap server not providing the requested data'
 
 # read lats,lons,times.
-print data.keys()
-print datau.keys()
-print datav.keys()
-latitudes = data['lat'][:]
-longitudes = data['lon'][:].tolist()
-times = data['time'][:]
+print data.variables.keys()
+print datau.variables.keys()
+print datav.variables.keys()
+latitudes = data.variables['lat'][:]
+longitudes = data.variables['lon'][:].tolist()
+times = data.variables['time'][:]
 # put times in YYYYMMDDHH format.
 dates=[]
 for t in times:
@@ -83,49 +81,49 @@
 if ntime1 >= ntime2:
 raise ValueError,'date2 must be greater than date1'
 # get sea level pressure and 10-m wind data.
-slpdata = data['presmsl']
-udata = datau['ugrdprs']
-vdata = datau['vgrdprs']
+slpdata = data.variables['presmsl']
+udata = datau.variables['ugrdprs']
+vdata = datau.variables['vgrdprs']
 # mult slp by 0.01 to put in units of millibars.
-slpin = 0.01*p.squeeze(slpdata[ntime1:ntime2+1,:,:])
-uin = p.squeeze(udata[ntime1:ntime2+1,0,:,:]) 
-vin = p.squeeze(vdata[ntime1:ntime2+1,0,:,:]) 
+slpin = 0.01*slpdata[ntime1:ntime2+1,:,:]
+uin = udata[ntime1:ntime2+1,0,:,:] 
+vin = vdata[ntime1:ntime2+1,0,:,:] 
 datelabels = dates[ntime1:ntime2+1]
 # add cyclic points
-slp = p.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),p.Float64)
+slp = numpy.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),numpy.float64)
 slp[:,:,0:-1] = slpin; slp[:,:,-1] = slpin[:,:,0]
-u = p.zeros((uin.shape[0],uin.shape[1],uin.shape[2]+1),p.Float64)
+u = numpy.zeros((uin.shape[0],uin.shape[1],uin.shape[2]+1),numpy.float64)
 u[:,:,0:-1] = uin; u[:,:,-1] = uin[:,:,0]
-v = p.zeros((vin.shape[0],vin.shape[1],vin.shape[2]+1),p.Float64)
+v = numpy.zeros((vin.shape[0],vin.shape[1],vin.shape[2]+1),numpy.float64)
 v[:,:,0:-1] = vin; v[:,:,-1] = vin[:,:,0]
-longitudes.append(360.); longitudes = p.array(longitudes)
+longitudes.append(360.); longitudes = numpy.array(longitudes)
 # make 2-d grid of lons, lats
-lons, lats = p.meshgrid(longitudes,latitudes)
+lons, lats = numpy.meshgrid(longitudes,latitudes)
 print 'min/max slp,u,v'
-print min(p.ravel(slp)),max(p.ravel(slp))
-print min(p.ravel(uin)),max(p.ravel(uin))
-print min(p.ravel(vin)),max(p.ravel(vin))
+print slp.min(), slp.max()
+print uin.min(), uin.max()
+print vin.min(), vin.max()
 print 'dates'
 print datelabels
-# make orthographic basemap.
+# make orthographic basemapylab.
 m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
-p.ion() # interactive mode on.
-uin = p.squeeze(udata[ntime1:ntime2+1,0,:,:]) 
-vin = p.squeeze(vdata[ntime1:ntime2+1,0,:,:]) 
+pylab.ion() # interactive mode on.
+uin = udata[ntime1:ntime2+1,0,:,:] 
+vin = vdata[ntime1:ntime2+1,0,:,:] 
 datelabels = dates[ntime1:ntime2+1]
-# make orthographic basemap.
+# make orthographic basemapylab.
 m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
-p.ion() # interactive mode on.
+pylab.ion() # interactive mode on.
 # create figure, add axes (leaving room for colorbar on right)
-fig = p.figure()
+fig = pylab.figure()
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # set desired contour levels.
-clevs = p.arange(960,1061,5)
+clevs = numpy.arange(960,1061,5)
 # compute native x,y coordinates of grid.
 x, y = m(lons, lats)
 # define parallels and meridians to draw.
-parallels = p.arange(-80.,90,20.)
-meridians = p.arange(0.,360.,20.)
+parallels = numpy.arange(-80.,90,20.)
+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()
@@ -133,42 +131,42 @@
 # parallels, meridians and title.
 for nt,date in enumerate(datelabels[1:]):
 CS = m.contour(x,y,slp[nt,:,:],clevs,linewidths=0.5,colors='k',animated=True)
- CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=p.cm.RdBu_r,animated=True)
+ CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=pylab.cm.RdBu_r,animated=True)
 # plot wind vectors on lat/lon grid.
 # rotate wind vectors to map projection coordinates.
 #urot,vrot = m.rotate_vector(u[nt,:,:],v[nt,:,:],lons,lats)
- # plot wind vectors over map.
+ # plot wind vectors over mapylab.
 #Q = m.quiver(x,y,urot,vrot,scale=500) 
 # plot wind vectors on projection grid (looks better).
 # first, shift grid so it goes from -180 to 180 (instead of 0 to 360
- # in longitude). Otherwise, interpolation is messed up.
+ # in longitude). Otherwise, interpolation is messed upylab.
 ugrid,newlons = shiftgrid(180.,u[nt,:,:],longitudes,start=False)
 vgrid,newlons = shiftgrid(180.,v[nt,:,:],longitudes,start=False)
 # transform vectors to projection grid.
 urot,vrot,xx,yy = m.transform_vector(ugrid,vgrid,newlons,latitudes,51,51,returnxy=True,masked=True)
- # plot wind vectors over map.
+ # plot wind vectors over mapylab.
 Q = m.quiver(xx,yy,urot,vrot,scale=500)
 # make quiver key.
- qk = p.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
+ qk = pylab.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
 # draw coastlines, parallels, meridians, title.
 m.drawcoastlines(linewidth=1.5)
 m.drawparallels(parallels)
 m.drawmeridians(meridians)
- p.title('SLP and Wind Vectors '+date)
+ pylab.title('SLP and Wind Vectors '+date)
 if nt == 0: # plot colorbar on a separate axes (only for first frame)
- cax = p.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
+ cax = pylab.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
 fig.colorbar(CS,drawedges=True, cax=cax) # draw colorbar
 cax.text(0.0,-0.05,'mb')
- p.axes(ax) # reset current axes
- p.draw() # draw the plot
+ pylab.axes(ax) # reset current axes
+ pylab.draw() # draw the plot
 # save first and last frame n1 times 
 # (so gif animation pauses at beginning and end)
 if nframe == 0 or nt == slp.shape[0]-1:
 for n in range(n1):
- p.savefig('anim%03i'%nframe+'.png')
+ pylab.savefig('anim%03i'%nframe+'.png')
 nframe = nframe + 1
 else:
- p.savefig('anim%03i'%nframe+'.png')
+ pylab.savefig('anim%03i'%nframe+'.png')
 nframe = nframe + 1
 ax.clear() # clear the axes for the next plot.
 
Modified: trunk/toolkits/basemap/examples/warpimage.py
===================================================================
--- trunk/toolkits/basemap/examples/warpimage.py	2007年11月30日 12:58:57 UTC (rev 4518)
+++ trunk/toolkits/basemap/examples/warpimage.py	2007年11月30日 14:36:43 UTC (rev 4519)
@@ -1,6 +1,7 @@
 import pylab as P
+import numpy
 from matplotlib.toolkits.basemap import Basemap
-from matplotlib.numerix import ma
+from numpy import ma
 from matplotlib.image import pil_to_array
 from PIL import Image
 
@@ -10,13 +11,13 @@
 # read in jpeg image to rgba array of normalized floats.
 pilImage = Image.open('land_shallow_topo_2048.jpg')
 rgba = pil_to_array(pilImage)
-rgba = rgba.astype(P.Float32)/255. # convert to normalized floats.
+rgba = rgba.astype(numpy.float32)/255. # convert to normalized floats.
 
 # define lat/lon grid that image spans (projection='cyl').
 nlons = rgba.shape[1]; nlats = rgba.shape[0]
 delta = 360./float(nlons)
-lons = P.arange(-180.+0.5*delta,180.,delta)
-lats = P.arange(-90.+0.5*delta,90.,delta)
+lons = numpy.arange(-180.+0.5*delta,180.,delta)
+lats = numpy.arange(-90.+0.5*delta,90.,delta)
 
 # create new figure
 fig=P.figure()
@@ -27,8 +28,8 @@
 # draw coastlines.
 m.drawcoastlines(linewidth=0.5,color='0.5')
 # draw lat/lon grid lines.
-m.drawmeridians(P.arange(-180,180,60),labels=[0,0,0,1],color='0.5')
-m.drawparallels(P.arange(-90,90,30),labels=[1,0,0,0],color='0.5')
+m.drawmeridians(numpy.arange(-180,180,60),labels=[0,0,0,1],color='0.5')
+m.drawparallels(numpy.arange(-90,90,30),labels=[1,0,0,0],color='0.5')
 P.title("Blue Marble image - native 'cyl' projection",fontsize=12)
 print 'plot cylindrical map (no warping needed) ...'
 
@@ -38,9 +39,9 @@
 m = Basemap(projection='ortho',lat_0=40,lon_0=40,resolution='l')
 # transform to nx x ny regularly spaced native projection grid
 # nx and ny chosen to have roughly the same horizontal res as original image.
-dx = 2.*P.pi*m.rmajor/float(nlons)
+dx = 2.*numpy.pi*m.rmajor/float(nlons)
 nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
-rgba_warped = ma.zeros((ny,nx,4),P.Float64)
+rgba_warped = ma.zeros((ny,nx,4),numpy.float64)
 # interpolate rgba values from proj='cyl' (geographic coords) to 'lcc'
 # values outside of projection limb will be masked.
 for k in range(4):
@@ -52,8 +53,8 @@
 # draw coastlines.
 m.drawcoastlines(linewidth=0.5,color='0.5')
 # draw lat/lon grid lines every 30 degrees.
-m.drawmeridians(P.arange(0,360,30),color='0.5')
-m.drawparallels(P.arange(-90,90,30),color='0.5')
+m.drawmeridians(numpy.arange(0,360,30),color='0.5')
+m.drawparallels(numpy.arange(-90,90,30),color='0.5')
 P.title("Blue Marble image warped from 'cyl' to 'ortho' projection",fontsize=12)
 print 'warp to orthographic map ...'
 
@@ -67,7 +68,7 @@
 # nx and ny chosen to have roughly the same horizontal res as original image.
 dx = 2.*P.pi*m.rmajor/float(nlons)
 nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
-rgba_warped = P.zeros((ny,nx,4),P.Float64)
+rgba_warped = numpy.zeros((ny,nx,4),numpy.float64)
 # interpolate rgba values from proj='cyl' (geographic coords) to 'lcc'
 for k in range(4):
 rgba_warped[:,:,k] = m.transform_scalar(rgba[:,:,k],lons,lats,nx,ny)
@@ -77,9 +78,9 @@
 m.drawcoastlines(linewidth=0.5,color='0.5')
 # draw parallels and meridians.
 # label on left, right and bottom of map.
-parallels = P.arange(0.,80,20.)
+parallels = numpy.arange(0.,80,20.)
 m.drawparallels(parallels,labels=[1,1,0,1],color='0.5')
-meridians = P.arange(10.,360.,30.)
+meridians = numpy.arange(10.,360.,30.)
 m.drawmeridians(meridians,labels=[1,1,0,1],color='0.5')
 P.title("Blue Marble image warped from 'cyl' to 'lcc' projection",fontsize=12)
 print 'warp to lambert conformal map ...'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2007年11月30日 14:43:12
Revision: 4520
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4520&view=rev
Author: jswhit
Date: 2007年11月30日 06:43:11 -0800 (2007年11月30日)
Log Message:
-----------
remove numerix imports
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/ccsm_popgrid.py
 trunk/toolkits/basemap/examples/fcstmaps.py
 trunk/toolkits/basemap/examples/fillstates.py
 trunk/toolkits/basemap/examples/plotmap_masked.py
 trunk/toolkits/basemap/examples/plotmap_oo.py
 trunk/toolkits/basemap/examples/simpletest_oo.py
Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py
===================================================================
--- trunk/toolkits/basemap/examples/ccsm_popgrid.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/ccsm_popgrid.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -22,13 +22,8 @@
 """
 import pylab as pl
 from matplotlib import rcParams
-try:
- import numpy
- rcParams['numerix'] = 'numpy'
-except:
- raise ImportError('this example requires numpy')
-import matplotlib.numerix.ma as MA
-import matplotlib.numerix as N
+from numpy import ma as MA
+import numpy as N
 from matplotlib.toolkits.basemap import Basemap, NetCDFFile
 
 # read in data from netCDF file.
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/fcstmaps.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -4,7 +4,7 @@
 meshgrid, axes, colorbar
 import numpy
 import sys
-from matplotlib.numerix import ma
+from numpy import ma
 import datetime
 from matplotlib.toolkits.basemap import Basemap, NetCDFFile, addcyclic
 
Modified: trunk/toolkits/basemap/examples/fillstates.py
===================================================================
--- trunk/toolkits/basemap/examples/fillstates.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/fillstates.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -1,5 +1,5 @@
 import pylab as p
-import matplotlib.numerix as nx
+import numpy
 from matplotlib.toolkits.basemap import Basemap as Basemap
 from matplotlib.colors import rgb2hex
 from matplotlib.patches import Polygon
@@ -90,7 +90,7 @@
 poly = Polygon(seg,facecolor=color,edgecolor=color)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(nx.arange(25,65,20),labels=[1,0,0,0])
-m.drawmeridians(nx.arange(-120,-40,20),labels=[0,0,0,1])
+m.drawparallels(numpy.arange(25,65,20),labels=[1,0,0,0])
+m.drawmeridians(numpy.arange(-120,-40,20),labels=[0,0,0,1])
 p.title('Filling State Polygons by Population Density')
 p.show()
Modified: trunk/toolkits/basemap/examples/plotmap_masked.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_masked.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -8,7 +8,7 @@
 from matplotlib.toolkits.basemap import Basemap, shiftgrid
 from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
 text, where
-from matplotlib.numerix import ma
+from numpy import ma
 import matplotlib.colors as colors
 
 # read in topo data (on a regular lat/lon grid)
Modified: trunk/toolkits/basemap/examples/plotmap_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_oo.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -14,7 +14,7 @@
 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
 from matplotlib.toolkits.basemap import Basemap, shiftgrid
 from matplotlib.figure import Figure
-import matplotlib.numerix as NX
+import numpy
 import matplotlib.cm as cm
 from matplotlib.mlab import load
 
@@ -57,9 +57,9 @@
 m.drawstates()
 # draw parallels and meridians.
 # label on left, right and bottom of map.
-parallels = NX.arange(0.,80,20.)
+parallels = numpy.arange(0.,80,20.)
 m.drawparallels(parallels,labels=[1,1,0,1])
-meridians = NX.arange(10.,360.,30.)
+meridians = numpy.arange(10.,360.,30.)
 m.drawmeridians(meridians,labels=[1,1,0,1])
 # set title.
 ax.set_title('ETOPO Topography - Lambert Conformal Conic')
Modified: trunk/toolkits/basemap/examples/simpletest_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/simpletest_oo.py	2007年11月30日 14:36:43 UTC (rev 4519)
+++ trunk/toolkits/basemap/examples/simpletest_oo.py	2007年11月30日 14:43:11 UTC (rev 4520)
@@ -7,8 +7,7 @@
 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
 from matplotlib.toolkits.basemap import Basemap
 from matplotlib.figure import Figure
-from numpy import meshgrid
-import matplotlib.numerix as nx
+import numpy
 import matplotlib.cm as cm
 from matplotlib.mlab import load
 
@@ -26,15 +25,15 @@
 # set 'ax' keyword so pylab won't be imported.
 m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]),ax=ax)
 # make filled contour plot.
-x, y = m(*meshgrid(lons, lats))
+x, y = m(*numpy.meshgrid(lons, lats))
 cs = m.contourf(x,y,etopo,30,cmap=cm.jet)
 # draw coastlines.
 m.drawcoastlines()
 # draw a line around the map region.
 m.drawmapboundary()
 # draw parallels and meridians.
-m.drawparallels(nx.arange(-60.,90.,30.),labels=[1,0,0,0],fontsize=10)
-m.drawmeridians(nx.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10)
+m.drawparallels(numpy.arange(-60.,90.,30.),labels=[1,0,0,0],fontsize=10)
+m.drawmeridians(numpy.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10)
 # add a title.
 ax.set_title('Robinson Projection')
 # add a colorbar.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2007年11月30日 17:33:00
Revision: 4528
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4528&view=rev
Author: jswhit
Date: 2007年11月30日 09:32:59 -0800 (2007年11月30日)
Log Message:
-----------
color ocean areas
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/garp.py
 trunk/toolkits/basemap/examples/geos_demo.py
Modified: trunk/toolkits/basemap/examples/garp.py
===================================================================
--- trunk/toolkits/basemap/examples/garp.py	2007年11月30日 16:16:34 UTC (rev 4527)
+++ trunk/toolkits/basemap/examples/garp.py	2007年11月30日 17:32:59 UTC (rev 4528)
@@ -32,9 +32,9 @@
 # 20 degree graticule.
 m.drawparallels(arange(-80,81,20))
 m.drawmeridians(arange(-180,180,20))
-# draw a red dot at the center.
+# draw a black dot at the center.
 xpt, ypt = m(lon_0, lat_0)
-m.plot([xpt],[ypt],'ro') 
+m.plot([xpt],[ypt],'ko') 
 # draw the title.
 title('The World According to Garp in '+location)
 show()
Modified: trunk/toolkits/basemap/examples/geos_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo.py	2007年11月30日 16:16:34 UTC (rev 4527)
+++ trunk/toolkits/basemap/examples/geos_demo.py	2007年11月30日 17:32:59 UTC (rev 4528)
@@ -24,7 +24,8 @@
 fig = figure()
 m = Basemap(projection='geos',lon_0=lon_0,satellite_height=h,rsphere=(6378137.00,6356752.3142),resolution='l')
 m.drawcoastlines()
-m.fillcontinents(color='coral')
+m.drawmapboundary(fill_color='aqua')
+m.fillcontinents(color='coral',lake_color='aqua')
 m.drawcountries()
 # draw parallels and meridians.
 m.drawparallels(arange(-90.,120.,30.))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2007年12月02日 14:24:33
Revision: 4545
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4545&view=rev
Author: jswhit
Date: 2007年12月02日 06:24:29 -0800 (2007年12月02日)
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.
From: <js...@us...> - 2007年12月05日 02:31:45
Revision: 4605
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4605&view=rev
Author: jswhit
Date: 2007年12月04日 18:31:36 -0800 (2007年12月04日)
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.
From: <js...@us...> - 2008年01月10日 13:21:57
Revision: 4839
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4839&view=rev
Author: jswhit
Date: 2008年01月10日 05:21:55 -0800 (2008年1月10日)
Log Message:
-----------
change import to 'from mpl_toolkits.basemap import Basemap'
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/ccsm_popgrid.py
 trunk/toolkits/basemap/examples/contour_demo.py
 trunk/toolkits/basemap/examples/customticks.py
 trunk/toolkits/basemap/examples/fcstmaps.py
 trunk/toolkits/basemap/examples/fillstates.py
 trunk/toolkits/basemap/examples/garp.py
 trunk/toolkits/basemap/examples/geos_demo.py
 trunk/toolkits/basemap/examples/geos_demo_2.py
 trunk/toolkits/basemap/examples/hires.py
 trunk/toolkits/basemap/examples/hurrtracks.py
 trunk/toolkits/basemap/examples/nytolondon.py
 trunk/toolkits/basemap/examples/ortho_demo.py
 trunk/toolkits/basemap/examples/panelplot.py
 trunk/toolkits/basemap/examples/plot_tissot.py
 trunk/toolkits/basemap/examples/plotcities.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/plotsst.py
 trunk/toolkits/basemap/examples/pnganim.py
 trunk/toolkits/basemap/examples/polarmaps.py
 trunk/toolkits/basemap/examples/quiver_demo.py
 trunk/toolkits/basemap/examples/randompoints.py
 trunk/toolkits/basemap/examples/setwh.py
 trunk/toolkits/basemap/examples/show_colormaps.py
 trunk/toolkits/basemap/examples/simpletest.py
 trunk/toolkits/basemap/examples/simpletest_oo.py
 trunk/toolkits/basemap/examples/test.py
 trunk/toolkits/basemap/examples/testgdal.py
 trunk/toolkits/basemap/examples/warpimage.py
 trunk/toolkits/basemap/examples/wiki_example.py
Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py
===================================================================
--- trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -24,7 +24,7 @@
 from matplotlib import rcParams
 from numpy import ma as MA
 import numpy as N
-from matplotlib.toolkits.basemap import Basemap, NetCDFFile
+from mpl_toolkits.basemap import Basemap, NetCDFFile
 
 # read in data from netCDF file.
 infile = 'ccsm_popgrid.nc'
Modified: trunk/toolkits/basemap/examples/contour_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/contour_demo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/contour_demo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap, shiftgrid
 from pylab import load, show, colorbar, axes, gca,\
 figure, title, meshgrid, cm, arange
 
Modified: trunk/toolkits/basemap/examples/customticks.py
===================================================================
--- trunk/toolkits/basemap/examples/customticks.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/customticks.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 import pylab, numpy
 from matplotlib.ticker import FuncFormatter
 
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/fcstmaps.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -6,7 +6,7 @@
 import sys
 from numpy import ma
 import datetime
-from matplotlib.toolkits.basemap import Basemap, NetCDFFile, addcyclic, num2date
+from mpl_toolkits.basemap import Basemap, NetCDFFile, addcyclic, num2date
 
 
 # today's date is default.
Modified: trunk/toolkits/basemap/examples/fillstates.py
===================================================================
--- trunk/toolkits/basemap/examples/fillstates.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/fillstates.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,6 +1,6 @@
 import pylab as p
 import numpy
-from matplotlib.toolkits.basemap import Basemap as Basemap
+from mpl_toolkits.basemap import Basemap as Basemap
 from matplotlib.colors import rgb2hex
 from matplotlib.patches import Polygon
 
Modified: trunk/toolkits/basemap/examples/garp.py
===================================================================
--- trunk/toolkits/basemap/examples/garp.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/garp.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import title, show, arange, pi
 
 # the shortest route from the center of the map
Modified: trunk/toolkits/basemap/examples/geos_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/geos_demo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import title, show, arange, figure
 
 # create Basemap instance for Geostationary (satellite view) projection.
Modified: trunk/toolkits/basemap/examples/geos_demo_2.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo_2.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/geos_demo_2.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -9,7 +9,7 @@
 
 """
 from PIL import Image
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import figure, cm, arange, colorbar, text, savefig, gcf, clim, title, show
 from matplotlib.image import pil_to_array
 
Modified: trunk/toolkits/basemap/examples/hires.py
===================================================================
--- trunk/toolkits/basemap/examples/hires.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/hires.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import show, title, arange, figure, clf
 import cPickle, time
 
Modified: trunk/toolkits/basemap/examples/hurrtracks.py
===================================================================
--- trunk/toolkits/basemap/examples/hurrtracks.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/hurrtracks.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -4,7 +4,7 @@
 ESRI shapefile data from http://www.nationalatlas.gov/atlasftp.html
 """
 import pylab as p
-from matplotlib.toolkits.basemap import Basemap as Basemap
+from mpl_toolkits.basemap import Basemap as Basemap
 # Lambert Conformal Conic map.
 m = Basemap(llcrnrlon=-100.,llcrnrlat=0.,urcrnrlon=-20.,urcrnrlat=57.,
 projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60.,
Modified: trunk/toolkits/basemap/examples/nytolondon.py
===================================================================
--- trunk/toolkits/basemap/examples/nytolondon.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/nytolondon.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,5 +1,5 @@
 # example demonstrating how to draw a great circle on a map.
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import title, arange, show, figure
 
 # setup lambert azimuthal map projection.
Modified: trunk/toolkits/basemap/examples/ortho_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/ortho_demo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/ortho_demo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import title, show, arange, figure
 
 # create Basemap instance for Orthographic (satellite view) projection.
Modified: trunk/toolkits/basemap/examples/panelplot.py
===================================================================
--- trunk/toolkits/basemap/examples/panelplot.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/panelplot.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from matplotlib import rcParams
 from matplotlib.ticker import MultipleLocator
 import pylab as P
Modified: trunk/toolkits/basemap/examples/plot_tissot.py
===================================================================
--- trunk/toolkits/basemap/examples/plot_tissot.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plot_tissot.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,5 +1,5 @@
 import pylab as p
-from matplotlib.toolkits.basemap import Basemap as Basemap
+from mpl_toolkits.basemap import Basemap as Basemap
 from matplotlib.patches import Polygon
 
 # Tissot's Indicatrix (http://en.wikipedia.org/wiki/Tissot's_Indicatrix). 
Modified: trunk/toolkits/basemap/examples/plotcities.py
===================================================================
--- trunk/toolkits/basemap/examples/plotcities.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotcities.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,7 +1,7 @@
 import pylab as p
 from matplotlib.mlab import prctile_rank
 import numpy
-from matplotlib.toolkits.basemap import Basemap as Basemap
+from mpl_toolkits.basemap import Basemap as Basemap
 
 # cities colored by population rank.
 
Modified: trunk/toolkits/basemap/examples/plotmap.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotmap.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -4,7 +4,7 @@
 
 # the data is interpolated to the native projection grid.
 
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap, shiftgrid
 from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
 text
 
Modified: trunk/toolkits/basemap/examples/plotmap_masked.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_masked.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -5,7 +5,7 @@
 # demonstrates use of masked arrays to mask out certain regions
 # (in this case the oceans)
 
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap, shiftgrid
 from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
 text, where
 from numpy import ma
Modified: trunk/toolkits/basemap/examples/plotmap_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_oo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -12,7 +12,7 @@
 matplotlib.use('Agg')
 
 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap, shiftgrid
 from matplotlib.figure import Figure
 import numpy
 import matplotlib.cm as cm
Modified: trunk/toolkits/basemap/examples/plotprecip.py
===================================================================
--- trunk/toolkits/basemap/examples/plotprecip.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotprecip.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap, cm, NetCDFFile
+from mpl_toolkits.basemap import Basemap, cm, NetCDFFile
 import pylab, copy
 from matplotlib import rcParams
 
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/plotsst.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap, NetCDFFile
+from mpl_toolkits.basemap import Basemap, NetCDFFile
 import pylab, numpy, sys
 # read in sea-surface temperature and ice data
 # can be a local file, a URL for a remote opendap dataset,
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/pnganim.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -8,7 +8,7 @@
 import pylab
 from numpy import ma
 import datetime, sys, time, subprocess
-from matplotlib.toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
+from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
 
 # times for March 1993 'storm of the century'
 YYYYMMDDHH1 = '1993031000'
Modified: trunk/toolkits/basemap/examples/polarmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/polarmaps.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/polarmaps.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -5,7 +5,7 @@
 
 # illustrates special-case polar-centric projections.
 
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import title, colorbar, show, axes, cm, load, arange, \
 figure, ravel, meshgrid
 
Modified: trunk/toolkits/basemap/examples/quiver_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/quiver_demo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/quiver_demo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 import numpy
 from pylab import show, title, arange, meshgrid, cm, figure, \
 colorbar, axes, gca, reshape, quiverkey
Modified: trunk/toolkits/basemap/examples/randompoints.py
===================================================================
--- trunk/toolkits/basemap/examples/randompoints.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/randompoints.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,6 +1,6 @@
 from pylab import show, title, arange, figure, title, arccos, pi, cm, text
 from matplotlib.colors import rgb2hex
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from numpy.random import uniform
 
 # Plot a bunch of randomly distributed points on the earth.
Modified: trunk/toolkits/basemap/examples/setwh.py
===================================================================
--- trunk/toolkits/basemap/examples/setwh.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/setwh.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,7 +1,7 @@
 # examples of using the 'width' and 'height' keywords
 # to the Basemap constructor.
 
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import arange, show, title, figure
 
 # setup projection parameters
Modified: trunk/toolkits/basemap/examples/show_colormaps.py
===================================================================
--- trunk/toolkits/basemap/examples/show_colormaps.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/show_colormaps.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,5 +1,5 @@
 import numpy, pylab
-from matplotlib.toolkits.basemap import cm
+from mpl_toolkits.basemap import cm
 a=numpy.outer(numpy.arange(0,1,0.01),numpy.ones(10))
 pylab.figure(figsize=(10,7))
 pylab.subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99)
Modified: trunk/toolkits/basemap/examples/simpletest.py
===================================================================
--- trunk/toolkits/basemap/examples/simpletest.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/simpletest.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from pylab import load, show, title, meshgrid, cm, arange
 # read in topo data (on a regular lat/lon grid)
 etopo=load('etopo20data.gz')
Modified: trunk/toolkits/basemap/examples/simpletest_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/simpletest_oo.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/simpletest_oo.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -5,7 +5,7 @@
 import matplotlib
 matplotlib.use('Agg')
 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from matplotlib.figure import Figure
 import numpy
 import matplotlib.cm as cm
Modified: trunk/toolkits/basemap/examples/test.py
===================================================================
--- trunk/toolkits/basemap/examples/test.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/test.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -3,7 +3,7 @@
 # country boundaries, filling continents and drawing
 # parallels/meridians
 
-from matplotlib.toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap, shiftgrid
 from pylab import show,arange,draw,figure,load,ravel,cm,axes,\
 colorbar,title,gca,pi,meshgrid
 import matplotlib.colors as colors
Modified: trunk/toolkits/basemap/examples/testgdal.py
===================================================================
--- trunk/toolkits/basemap/examples/testgdal.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/testgdal.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -7,7 +7,7 @@
 http://edcftp.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
 """
 import gdal
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from gdalconst import *
 import pylab as p
 
Modified: trunk/toolkits/basemap/examples/warpimage.py
===================================================================
--- trunk/toolkits/basemap/examples/warpimage.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/warpimage.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,6 +1,6 @@
 import pylab as P
 import numpy
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 from numpy import ma
 from matplotlib.image import pil_to_array
 from PIL import Image
Modified: trunk/toolkits/basemap/examples/wiki_example.py
===================================================================
--- trunk/toolkits/basemap/examples/wiki_example.py	2008年01月10日 13:15:37 UTC (rev 4838)
+++ trunk/toolkits/basemap/examples/wiki_example.py	2008年01月10日 13:21:55 UTC (rev 4839)
@@ -1,4 +1,4 @@
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
 import pylab as p
 # set up orthographic map projection with
 # perspective of satellite looking down at 50N, 100W.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年01月23日 13:33:30
Revision: 4887
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4887&view=rev
Author: jswhit
Date: 2008年01月23日 05:33:01 -0800 (2008年1月23日)
Log Message:
-----------
remove backwards compatibility kludge for ax.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/contour_demo.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -22,11 +22,8 @@
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
 # 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)
+l, b, w, h = pos.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
@@ -52,7 +49,7 @@
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -78,7 +75,7 @@
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -104,7 +101,7 @@
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -131,7 +128,7 @@
 CS = m.contour(x,y,hgt,15,linewidths=0.5,colors='k')
 CS = m.contourf(x,y,hgt,15,cmap=cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/panelplot.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -28,7 +28,7 @@
 CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.Spectral)
 # colorbar on bottom.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -51,7 +51,7 @@
 CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.Spectral)
 # colorbar on bottom.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -74,7 +74,7 @@
 CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.RdBu)
 # colorbar on right
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -89,7 +89,7 @@
 CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.RdBu)
 # colorbar on right.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/plotmap.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -32,11 +32,8 @@
 # plot image over map with imshow.
 im = m.imshow(topodat,cm.jet)
 # 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)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -40,11 +40,8 @@
 # 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.
-# 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)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -45,11 +45,8 @@
 # plot image over map with imshow.
 im = m.imshow(topodat,cm.jet)
 # 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)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/plotprecip.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -52,7 +52,7 @@
 cs = m.contourf(x,y,data,clevs,cmap=cm.s3pcpn)
 # new axis for colorbar.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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) 
@@ -78,7 +78,7 @@
 im2.set_cmap(cm.s3pcpn_l)
 # new axis for colorbar.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/pnganim.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -99,7 +99,7 @@
 # number of repeated frames at beginning and end is n1.
 nframe = 0; n1 = 10
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/simpletest_oo.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -37,11 +37,8 @@
 # add a title.
 ax.set_title('Robinson Projection')
 # add a colorbar.
-# 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)
+l, b, w, h = pos.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	2008年01月23日 13:20:03 UTC (rev 4886)
+++ trunk/toolkits/basemap/examples/test.py	2008年01月23日 13:33:01 UTC (rev 4887)
@@ -30,11 +30,8 @@
 # plot image over map.
 im = m.imshow(topoin,cm.jet)
 # 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)
+l, b, w, h = pos.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
@@ -114,7 +111,7 @@
 # get current axis instance.
 ax = gca()
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -146,7 +143,7 @@
 # get current axis instance.
 ax = gca()
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -179,7 +176,7 @@
 # get current axis instance.
 ax = gca()
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -211,7 +208,7 @@
 # get current axis instance.
 ax = gca()
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -245,7 +242,7 @@
 # get current axis instance.
 ax = gca()
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -276,7 +273,7 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -309,7 +306,7 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -344,7 +341,7 @@
 im = m.imshow(topodat,cm.jet)
 im.set_clim(-4000.,3000.) # adjust range of colors.
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -379,7 +376,7 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -410,7 +407,7 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -442,7 +439,7 @@
 # plot image over map.
 im = m.imshow(topodat,cm.jet)
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -483,7 +480,7 @@
 # - see contour_demo.py)
 im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -524,7 +521,7 @@
 # - see contour_demo.py)
 im = m.imshow(topo,palette,norm=colors.normalize(clip=False))
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -552,7 +549,7 @@
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -579,7 +576,7 @@
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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
@@ -606,7 +603,7 @@
 x,y = m(*meshgrid(lonsin,latsin))
 p = m.pcolormesh(x,y,topodatin,shading='flat')
 pos = ax.get_position()
-l, b, w, h = getattr(pos, 'bounds', pos)
+l, b, w, h = pos.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.
From: <js...@us...> - 2008年02月14日 21:52:01
Revision: 4963
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4963&view=rev
Author: jswhit
Date: 2008年02月14日 13:51:58 -0800 (2008年2月14日)
Log Message:
-----------
update blue marble image
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/warpimage.py
Added Paths:
-----------
 trunk/toolkits/basemap/examples/bmng.jpg
Added: trunk/toolkits/basemap/examples/bmng.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/toolkits/basemap/examples/bmng.jpg
___________________________________________________________________
Name: svn:mime-type
 + application/octet-stream
Modified: trunk/toolkits/basemap/examples/warpimage.py
===================================================================
--- trunk/toolkits/basemap/examples/warpimage.py	2008年02月13日 21:48:38 UTC (rev 4962)
+++ trunk/toolkits/basemap/examples/warpimage.py	2008年02月14日 21:51:58 UTC (rev 4963)
@@ -6,10 +6,10 @@
 from PIL import Image
 
 # shows how to warp an image from one map projection to another.
-# image from http://visibleearth.nasa.gov/
+# 'blue marble next generation' image from http://visibleearth.nasa.gov/
 
 # read in jpeg image to rgba array of normalized floats.
-pilImage = Image.open('land_shallow_topo_2048.jpg')
+pilImage = Image.open('bmng.jpg')
 rgba = pil_to_array(pilImage)
 rgba = rgba.astype(numpy.float32)/255. # convert to normalized floats.
 
@@ -84,4 +84,30 @@
 m.drawmeridians(meridians,labels=[1,1,0,1],color='0.5')
 P.title("Blue Marble image warped from 'cyl' to 'lcc' projection",fontsize=12)
 print 'warp to lambert conformal map ...'
+
+# create new figure
+fig=P.figure()
+# define oblique mercator map.
+m = Basemap(height=24000000,width=12000000,
+ resolution=None,projection='omerc',\
+ lon_0=-100,lat_0=15,lon_2=-120,lat_2=65,lon_1=-50,lat_1=-55)
+# transform to nx x ny regularly spaced native projection grid
+# nx and ny chosen to have roughly the same horizontal res as original image.
+dx = 2.*numpy.pi*m.rmajor/float(nlons)
+nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
+rgba_warped = ma.zeros((ny,nx,4),numpy.float64)
+# interpolate rgba values from proj='cyl' (geographic coords) to 'lcc'
+# values outside of projection limb will be masked.
+for k in range(4):
+ rgba_warped[:,:,k] = m.transform_scalar(rgba[:,:,k],lons,lats,nx,ny,masked=False)
+# make points outside projection limb transparent.
+rgba_warped = rgba_warped.filled(0.)
+# plot warped rgba image.
+im = m.imshow(rgba_warped)
+# draw lat/lon grid lines every 20 degrees.
+m.drawmeridians(numpy.arange(0,360,20),color='0.5')
+m.drawparallels(numpy.arange(-80,81,20),color='0.5')
+P.title("Blue Marble image warped from 'cyl' to 'omerc' projection",fontsize=12)
+print 'warp to oblique mercator map ...'
+
 P.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年05月17日 11:52:25
Revision: 5166
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5166&view=rev
Author: jswhit
Date: 2008年05月17日 04:52:15 -0700 (2008年5月17日)
Log Message:
-----------
convert to pyplot/numpy namespace
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/plotmap.py
 trunk/toolkits/basemap/examples/plotmap_masked.py
 trunk/toolkits/basemap/examples/plotmap_oo.py
Modified: trunk/toolkits/basemap/examples/plotmap.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap.py	2008年05月16日 22:47:00 UTC (rev 5165)
+++ trunk/toolkits/basemap/examples/plotmap.py	2008年05月17日 11:52:15 UTC (rev 5166)
@@ -5,14 +5,15 @@
 # the data is interpolated to the native projection grid.
 
 from mpl_toolkits.basemap import Basemap, shiftgrid
-from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
- text
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
 
 # read in topo data (on a regular lat/lon grid)
 # longitudes go from 20 to 380.
-topoin = load('etopo20data.gz')
-lons = load('etopo20lons.gz')
-lats = load('etopo20lats.gz')
+topoin = mlab.load('etopo20data.gz')
+lons = mlab.load('etopo20lons.gz')
+lats = mlab.load('etopo20lats.gz')
 # shift data so lons go from -180 to 180 instead of 20 to 380.
 topoin,lons = shiftgrid(180.,topoin,lons,start=False)
 
@@ -26,31 +27,32 @@
 nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
 topodat,x,y = m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True)
 # create the figure.
-fig=figure(figsize=(8,8))
+fig=plt.figure(figsize=(8,8))
 # add an axes, leaving room for colorbar on the right.
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map with imshow.
-im = m.imshow(topodat,cm.jet)
+im = m.imshow(topodat,plt.cm.jet)
 # setup colorbar axes instance.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
-cax = axes([l+w+0.075, b, 0.05, h])
-colorbar(cax=cax) # draw colorbar
-axes(ax) # make the original axes current again
+cax = plt.axes([l+w+0.075, b, 0.05, h])
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
 # plot blue dot on boulder, colorado and label it as such.
 xpt,ypt = m(-104.237,40.125) 
 m.plot([xpt],[ypt],'bo') 
-text(xpt+100000,ypt+100000,'Boulder')
+plt.text(xpt+100000,ypt+100000,'Boulder')
 # draw coastlines and political boundaries.
 m.drawcoastlines()
 m.drawcountries()
 m.drawstates()
 # draw parallels and meridians.
 # label on left, right and bottom of map.
-parallels = arange(0.,80,20.)
+parallels = np.arange(0.,80,20.)
 m.drawparallels(parallels,labels=[1,1,0,1])
-meridians = arange(10.,360.,30.)
+meridians = np.arange(10.,360.,30.)
 m.drawmeridians(meridians,labels=[1,1,0,1])
 # set title.
-title('ETOPO Topography - Lambert Conformal Conic')
-show()
+plt.title('ETOPO Topography - Lambert Conformal Conic')
+#plt.savefig('plotmap.pdf')
+plt.show()
Modified: trunk/toolkits/basemap/examples/plotmap_masked.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_masked.py	2008年05月16日 22:47:00 UTC (rev 5165)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py	2008年05月17日 11:52:15 UTC (rev 5166)
@@ -6,16 +6,17 @@
 # (in this case the oceans)
 
 from mpl_toolkits.basemap import Basemap, shiftgrid
-from pylab import title, colorbar, show, axes, cm, load, arange, figure, \
- text, where
 from numpy import ma
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
 import matplotlib.colors as colors
 
 # read in topo data (on a regular lat/lon grid)
 # longitudes go from 20 to 380.
-topoin = load('etopo20data.gz')
-lonsin = load('etopo20lons.gz')
-latsin = load('etopo20lats.gz')
+topoin = mlab.load('etopo20data.gz')
+lonsin = mlab.load('etopo20lons.gz')
+latsin = mlab.load('etopo20lats.gz')
 # shift data so lons go from -180 to 180 instead of 20 to 380.
 topoin,lonsin = shiftgrid(180.,topoin,lonsin,start=False)
 
@@ -29,36 +30,36 @@
 nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
 topodat,x,y = m.transform_scalar(topoin,lonsin,latsin,nx,ny,returnxy=True)
 # create the figure.
-fig=figure(figsize=(8,8))
+fig=plt.figure(figsize=(8,8))
 # add an axes, leaving room for colorbar on the right.
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # make topodat a masked array, masking values lower than sea level.
-topodat = where(topodat < 0.,1.e10,topodat)
+topodat = np.where(topodat < 0.,1.e10,topodat)
 topodatm = ma.masked_values(topodat, 1.e10)
-palette = cm.YlOrRd
+palette = plt.cm.YlOrRd
 palette.set_bad('aqua', 1.0)
 # 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.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
-cax = axes([l+w+0.075, b, 0.05, h])
-colorbar(cax=cax) # draw colorbar
-axes(ax) # make the original axes current again
+cax = plt.axes([l+w+0.075, b, 0.05, h])
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
 # plot blue dot on boulder, colorado and label it as such.
 xpt,ypt = m(-104.237,40.125) 
 m.plot([xpt],[ypt],'bo') 
-text(xpt+100000,ypt+100000,'Boulder')
+plt.text(xpt+100000,ypt+100000,'Boulder')
 # draw coastlines and political boundaries.
 m.drawcoastlines()
 m.drawcountries()
 m.drawstates()
 # draw parallels and meridians.
 # label on left, right and bottom of map.
-parallels = arange(0.,80,20.)
+parallels = np.arange(0.,80,20.)
 m.drawparallels(parallels,labels=[1,1,0,1])
-meridians = arange(10.,360.,30.)
+meridians = np.arange(10.,360.,30.)
 m.drawmeridians(meridians,labels=[1,1,0,1])
 # set title.
-title('Masked ETOPO Topography - via imshow')
-show()
+plt.title('Masked ETOPO Topography - via imshow')
+plt.show()
Modified: trunk/toolkits/basemap/examples/plotmap_oo.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_oo.py	2008年05月16日 22:47:00 UTC (rev 5165)
+++ trunk/toolkits/basemap/examples/plotmap_oo.py	2008年05月17日 11:52:15 UTC (rev 5166)
@@ -5,7 +5,7 @@
 # the data is interpolated to the native projection grid.
 
 ##################################
-# pylab-free version of plotmap.py
+# pyplot/pylab-free version of plotmap.py
 ##################################
 # set backend to Agg.
 import matplotlib
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年05月20日 11:52:18
Revision: 5196
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5196&view=rev
Author: jswhit
Date: 2008年05月20日 04:52:12 -0700 (2008年5月20日)
Log Message:
-----------
convert more examples to numpy/pyplot namespace
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/README
 trunk/toolkits/basemap/examples/customticks.py
 trunk/toolkits/basemap/examples/fcstmaps.py
 trunk/toolkits/basemap/examples/geos_demo.py
 trunk/toolkits/basemap/examples/geos_demo_2.py
 trunk/toolkits/basemap/examples/geos_demo_3.py
 trunk/toolkits/basemap/examples/hires.py
 trunk/toolkits/basemap/examples/nytolondon.py
 trunk/toolkits/basemap/examples/ortho_demo.py
 trunk/toolkits/basemap/examples/plotcities.py
 trunk/toolkits/basemap/examples/quiver_demo.py
 trunk/toolkits/basemap/examples/randompoints.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/README	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -52,6 +52,9 @@
 from a jpeg file, then plot only a portion of the full earth (contributed
 by Scott Sinclair, requires PIL).
 
+geos_demo_3.py shows how to make a regional geostationary or orthographic 
+plot, where part of the region is outside the projection limb.
+
 fcstmaps.py is a sample multi-panel plot that accesses
 data over http using the dap module. An internet connection is required.
 
Modified: trunk/toolkits/basemap/examples/customticks.py
===================================================================
--- trunk/toolkits/basemap/examples/customticks.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/customticks.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,37 +1,38 @@
 from mpl_toolkits.basemap import Basemap
-import pylab, numpy
+import numpy as np
+import matplotlib.pyplot as plt
 from matplotlib.ticker import FuncFormatter
 
 # example showing how to create custom tick labels for a cylindrical
 # projection.
 
 def lat2str(deg):
- min = 60 * (deg - numpy.floor(deg))
- deg = numpy.floor(deg)
+ min = 60 * (deg - np.floor(deg))
+ deg = np.floor(deg)
 dir = 'N'
 if deg < 0:
 if min != 0.0:
 deg += 1.0
 min -= 60.0
 dir = 'S'
- return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg),numpy.abs(min),dir)
+ return (u"%d\N{DEGREE SIGN} %g' %s") % (np.abs(deg),np.abs(min),dir)
 
 def lon2str(deg):
- min = 60 * (deg - numpy.floor(deg))
- deg = numpy.floor(deg)
+ min = 60 * (deg - np.floor(deg))
+ deg = np.floor(deg)
 dir = 'E'
 if deg < 0:
 if min != 0.0:
 deg += 1.0
 min -= 60.0
 dir = 'W'
- return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg),numpy.abs(min),dir)
+ return (u"%d\N{DEGREE SIGN} %g' %s") % (np.abs(deg),np.abs(min),dir)
 
 # (1) use matplotlib custom tick formatter
 # instead of Basemap labelling methods.
 
 # create figure.
-fig=pylab.figure()
+fig=plt.figure()
 # create Basemap instance (regular lat/lon projection).
 # suppress_ticks=False allows custom axes ticks to be used
 # Ticks are suppressed by default, so Basemap methods
@@ -44,7 +45,7 @@
 # background color will be used for oceans.
 m.drawmapboundary(fill_color='aqua')
 # get axes instance.
-ax = pylab.gca()
+ax = plt.gca()
 # add custom ticks.
 # This only works for projection='cyl'.
 def xformat(x, pos=None): return lon2str(x)
@@ -62,7 +63,7 @@
 # custom formatting function with the 'fmt' keyword.
 
 # create figure.
-fig = pylab.figure()
+fig = plt.figure()
 # create Basemap instance.
 m = Basemap(llcrnrlon=-156.5,llcrnrlat=18.75,urcrnrlon=-154.5,urcrnrlat=20.5,
 resolution='h',projection='cyl')
@@ -73,8 +74,8 @@
 m.drawmapboundary(fill_color='aqua')
 # label meridians and parallels, passing string formatting function
 # with 'fmt' keyword.
-m.drawparallels(numpy.linspace(18,21,7),labels=[1,0,0,0],fmt=lat2str,dashes=[2,2])
-m.drawmeridians(numpy.linspace(-157,-154,7),labels=[0,0,0,1],fmt=lon2str,dashes=[2,2])
-pylab.title('Hawaii')
+m.drawparallels(np.linspace(18,21,7),labels=[1,0,0,0],fmt=lat2str,dashes=[2,2])
+m.drawmeridians(np.linspace(-157,-154,7),labels=[0,0,0,1],fmt=lon2str,dashes=[2,2])
+plt.title('Hawaii')
 
-pylab.show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/fcstmaps.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,8 +1,7 @@
 # this example reads today's numerical weather forecasts 
 # from the NOAA OpenDAP servers and makes a multi-panel plot.
-from pylab import title, show, figure, cm, figtext, \
- meshgrid, axes, colorbar
-import numpy
+import numpy as np
+import matplotlib.pyplot as plt
 import sys
 from numpy import ma
 import datetime
@@ -57,7 +56,7 @@
 
 t2mvar = data.variables['tmp2m']
 t2min = t2mvar[0:ntimes,:,:]
-t2m = numpy.zeros((ntimes,nlats,nlons+1),t2min.dtype)
+t2m = np.zeros((ntimes,nlats,nlons+1),t2min.dtype)
 # create Basemap instance for Orthographic projection.
 m = Basemap(lon_0=-90,lat_0=60,projection='ortho')
 # add wrap-around point in longitude.
@@ -66,25 +65,26 @@
 # convert to celsius.
 t2m = t2m-273.15
 # contour levels
-clevs = numpy.arange(-30,30.1,2.)
-lons, lats = meshgrid(lons, lats)
+clevs = np.arange(-30,30.1,2.)
+lons, lats = np.meshgrid(lons, lats)
 x, y = m(lons, lats)
 # create figure.
-fig=figure(figsize=(6,8))
+fig=plt.figure(figsize=(6,8))
 # make subplots.
 for nt,fcsthr in enumerate(fcsthrs):
 ax = fig.add_subplot(321+nt)
- cs = m.contourf(x,y,t2m[nt,:,:],clevs,cmap=cm.jet,extend='both')
+ cs = m.contourf(x,y,t2m[nt,:,:],clevs,cmap=plt.cm.jet,extend='both')
 m.drawcoastlines(linewidth=0.5)
 m.drawcountries()
- m.drawparallels(numpy.arange(-80,81,20))
- m.drawmeridians(numpy.arange(0,360,20))
+ m.drawparallels(np.arange(-80,81,20))
+ m.drawmeridians(np.arange(0,360,20))
 # panel title
- title('%d-h forecast valid '%fcsthr+verifdates[nt],fontsize=9)
+ plt.title('%d-h forecast valid '%fcsthr+verifdates[nt],fontsize=9)
 # figure title
-figtext(0.5,0.95,u"2-m temp (\N{DEGREE SIGN}C) forecasts from %s"%verifdates[0],
- horizontalalignment='center',fontsize=14)
+plt.figtext(0.5,0.95,
+ u"2-m temp (\N{DEGREE SIGN}C) forecasts from %s"%verifdates[0],
+ horizontalalignment='center',fontsize=14)
 # a single colorbar.
-cax = axes([0.1, 0.03, 0.8, 0.025])
-colorbar(cax=cax, orientation='horizontal')
-show()
+cax = plt.axes([0.1, 0.03, 0.8, 0.025])
+plt.colorbar(cax=cax, orientation='horizontal')
+plt.show()
Modified: trunk/toolkits/basemap/examples/geos_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/geos_demo.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,11 +1,12 @@
 from mpl_toolkits.basemap import Basemap
-from pylab import title, show, arange, figure
+import numpy as np
+import matplotlib.pyplot as plt
 
 # create Basemap instance for Geostationary (satellite view) projection.
 lon_0 = float(raw_input('enter reference longitude (lon_0):'))
 
 # map with land/sea mask plotted
-fig=figure()
+fig=plt.figure()
 m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution=None)
 # plot land-sea mask.
 rgba_land = (0,255,0,255) # land green.
@@ -13,21 +14,21 @@
 # lakes=True means plot inland lakes with ocean color.
 m.drawlsmask(rgba_land, rgba_ocean, lakes=True)
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary()
-title('Geostationary Map Centered on Lon=%s' % (lon_0))
+plt.title('Geostationary Map Centered on Lon=%s' % (lon_0))
 
 # map with continents drawn and filled.
-fig = figure()
+fig = plt.figure()
 m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution='l')
 m.drawcoastlines()
 m.drawmapboundary(fill_color='aqua')
 m.fillcontinents(color='coral',lake_color='aqua')
 m.drawcountries()
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary()
-title('Geostationary Map Centered on Lon=%s' % (lon_0))
-show()
+plt.title('Geostationary Map Centered on Lon=%s' % (lon_0))
+plt.show()
Modified: trunk/toolkits/basemap/examples/geos_demo_2.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo_2.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/geos_demo_2.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -10,7 +10,8 @@
 """
 from PIL import Image
 from mpl_toolkits.basemap import Basemap
-from pylab import figure, cm, arange, colorbar, text, savefig, gcf, clim, title, show
+import numpy as np
+import matplotlib.pyplot as plt
 from matplotlib.image import pil_to_array
 
 plot_name = 'geos_demo.png'
@@ -30,25 +31,25 @@
 lon_0 = 0.0
 satellite_height = 35785831.0
 
-fig = figure(figsize=(7,7))
+fig = plt.figure(figsize=(7,7))
 ax = fig.add_axes((0.1,0.1,0.8,0.8))
 # create Basemap instance for a Geostationary projection.
 m = Basemap(projection='geos', lon_0=lon_0, satellite_height=satellite_height,
 resolution='l', llcrnrlon=ll_lon, llcrnrlat=ll_lat, urcrnrlon=ur_lon, urcrnrlat=ur_lat)
 # add data
-m.imshow(data, cmap=cm.gray, interpolation='nearest')
-clim(0, 255)
+m.imshow(data, cmap=plt.cm.gray, interpolation='nearest')
+plt.clim(0, 255)
 # draw coastlines.
 m.drawcoastlines(linewidth=0.5, color=overlay_color)
 m.drawcountries(linewidth=0.5, color=overlay_color)
 # can't label meridians on bottom, because labels would
 # be outside map projection region.
-m.drawmeridians(arange(10,76,5), labels=[0,0,1,0], color=overlay_color)
-m.drawparallels(arange(-90,90,5), labels=[1,0,0,0], color=overlay_color)
+m.drawmeridians(np.arange(10,76,5), labels=[0,0,1,0], color=overlay_color)
+m.drawparallels(np.arange(-90,90,5), labels=[1,0,0,0], color=overlay_color)
 # add a colobar
-#colorbar()
+#plt.colorbar()
 # add timestamp and save
-fig = gcf()
+fig = plt.gcf()
 fig.text(x=0.275, y=0.025, s=u'Meteosat-9 VIS 0.6 channel - 12:00 UTC 04/06/2007\n \N{COPYRIGHT SIGN} EUMETSAT 2007',
 horizontalalignment='left',
 verticalalignment='bottom',
@@ -56,8 +57,8 @@
 fontweight='bold',
 bbox=dict(facecolor='gray', alpha=0.25, pad=15))
 fig.set_size_inches((8, 6))
-title('Meteosat Geostationary Satellite Image - Portion of Full Earth',y=1.05,fontsize=12)
+plt.title('Meteosat Geostationary Satellite Image - Portion of Full Earth',y=1.05,fontsize=12)
 
-show()
+plt.show()
 #fig.savefig(plot_name)
 #print 'Plot saved to %s' % (plot_name)
Modified: trunk/toolkits/basemap/examples/geos_demo_3.py
===================================================================
--- trunk/toolkits/basemap/examples/geos_demo_3.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/geos_demo_3.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,7 +1,8 @@
 from mpl_toolkits.basemap import Basemap
-from pylab import title, show, arange, figure
+import numpy as np
+import matplotlib.pyplot as plt
 
-fig = figure()
+fig = plt.figure()
 lon_0=57
 # global geos map
 m1 = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution=None)
@@ -13,12 +14,12 @@
 m.fillcontinents(color='coral',lake_color='aqua')
 m.drawcountries()
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary()
-title('Geostationary Map Centered on Lon=%s' % lon_0)
+plt.title('Geostationary Map Centered on Lon=%s' % lon_0)
 
-fig = figure()
+fig = plt.figure()
 # global ortho map
 lat_0=10.
 m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
@@ -30,9 +31,9 @@
 m.fillcontinents(color='coral',lake_color='aqua')
 m.drawcountries()
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary()
-title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
+plt.title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
 
-show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/hires.py
===================================================================
--- trunk/toolkits/basemap/examples/hires.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/hires.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,16 +1,17 @@
 from mpl_toolkits.basemap import Basemap
-from pylab import show, title, arange, figure, clf
+import numpy as np
+import matplotlib.pyplot as plt
 import cPickle, time
 
 # create figure with aqua background (will be oceans)
-fig = figure()
+fig = plt.figure()
 
 # create Basemap instance. Use 'high' resolution coastlines.
 t1 = time.clock()
 #m = Basemap(llcrnrlon=-10.5,llcrnrlat=49.5,urcrnrlon=3.5,urcrnrlat=59.5,
 # resolution='h',projection='tmerc',lon_0=-4,lat_0=0)
 m = Basemap(width=920000,height=1100000,
- resolution='h',projection='tmerc',lon_0=-4.2,lat_0=54.6)
+ resolution='f',projection='tmerc',lon_0=-4.2,lat_0=54.6)
 # make sure countries and rivers are loaded
 m.drawcountries()
 m.drawrivers()
@@ -20,7 +21,7 @@
 cPickle.dump(m,open('map.pickle','wb'),-1)
 
 # clear the figure
-clf()
+plt.clf()
 # read cPickle back in and plot it again (should be much faster).
 t1 = time.clock()
 m2 = cPickle.load(open('map.pickle','rb'))
@@ -37,10 +38,10 @@
 m.drawrivers(color='b')
 print time.clock()-t1,' secs to plot using using a pickled Basemap instance'
 # draw parallels
-circles = arange(48,65,2).tolist()
+circles = np.arange(48,65,2).tolist()
 m.drawparallels(circles,labels=[1,1,0,0])
 # draw meridians
-meridians = arange(-12,13,2)
+meridians = np.arange(-12,13,2)
 m.drawmeridians(meridians,labels=[0,0,1,1])
-title("High-Res British Isles",y=1.04)
-show()
+plt.title("High-Res British Isles",y=1.04)
+plt.show()
Modified: trunk/toolkits/basemap/examples/nytolondon.py
===================================================================
--- trunk/toolkits/basemap/examples/nytolondon.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/nytolondon.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,10 +1,11 @@
 # example demonstrating how to draw a great circle on a map.
 from mpl_toolkits.basemap import Basemap
-from pylab import title, arange, show, figure
+import numpy as np
+import matplotlib.pyplot as plt
 
 # setup lambert azimuthal map projection.
 # create new figure
-fig=figure()
+fig=plt.figure()
 m = Basemap(llcrnrlon=-100.,llcrnrlat=20.,urcrnrlon=20.,urcrnrlat=60.,\
 rsphere=(6378137.00,6356752.3142),\
 resolution='c',area_thresh=10000.,projection='merc',\
@@ -24,16 +25,16 @@
 m.drawcoastlines()
 m.fillcontinents()
 # draw parallels
-circles = arange(10,90,20)
+circles = np.arange(10,90,20)
 m.drawparallels(circles,labels=[1,1,0,1])
 # draw meridians
-meridians = arange(-180,180,30)
+meridians = np.arange(-180,180,30)
 m.drawmeridians(meridians,labels=[1,1,0,1])
-title('Great Circle from New York to London (Mercator)')
+plt.title('Great Circle from New York to London (Mercator)')
 print 'plotting Great Circle from New York to London (Mercator)'
 
 # create new figure
-fig=figure()
+fig=plt.figure()
 # setup a gnomonic projection.
 m = Basemap(llcrnrlon=-100.,llcrnrlat=20.,urcrnrlon=20.,urcrnrlat=60.,\
 resolution='c',area_thresh=10000.,projection='gnom',\
@@ -53,11 +54,11 @@
 m.drawcoastlines()
 m.fillcontinents()
 # draw parallels
-circles = arange(10,90,20)
+circles = np.arange(10,90,20)
 m.drawparallels(circles,labels=[0,1,0,0])
 # draw meridians
-meridians = arange(-180,180,30)
+meridians = np.arange(-180,180,30)
 m.drawmeridians(meridians,labels=[1,1,0,1])
-title('Great Circle from New York to London (Gnomonic)')
+plt.title('Great Circle from New York to London (Gnomonic)')
 print 'plotting Great Circle from New York to London (Gnomonic)'
-show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/ortho_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/ortho_demo.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/ortho_demo.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,12 +1,13 @@
 from mpl_toolkits.basemap import Basemap
-from pylab import title, show, arange, figure
+import numpy as np
+import matplotlib.pyplot as plt
 
 # create Basemap instance for Orthographic (satellite view) projection.
 lon_0 = float(raw_input('enter reference longitude (lon_0):'))
 lat_0 = float(raw_input('enter reference latitude (lat_0):'))
 
 # map with land/sea mask plotted
-fig = figure()
+fig = plt.figure()
 m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
 # plot land-sea mask.
 rgba_land = (0,255,0,255) # land green.
@@ -14,20 +15,20 @@
 # lakes=True means plot inland lakes with ocean color.
 m.drawlsmask(rgba_land, rgba_ocean, lakes=True)
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary()
-title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
+plt.title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
 
 # map with continents drawn and filled.
-fig = figure()
+fig = plt.figure()
 m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l')
 m.drawcoastlines()
 m.fillcontinents(color='coral',lake_color='aqua')
 m.drawcountries()
 # draw parallels and meridians.
-m.drawparallels(arange(-90.,120.,30.))
-m.drawmeridians(arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 m.drawmapboundary(fill_color='aqua')
 # add a map scale.
 length = 5000 
@@ -35,5 +36,5 @@
 lon1,lat1 = m(x1,y1,inverse=True)
 m.drawmapscale(lon1,lat1,lon_0,lat_0,length,fontsize=8,barstyle='fancy',\
 labelstyle='fancy',units='km')
-title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
-show()
+plt.title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0))
+plt.show()
Modified: trunk/toolkits/basemap/examples/plotcities.py
===================================================================
--- trunk/toolkits/basemap/examples/plotcities.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/plotcities.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,6 +1,5 @@
-import pylab as p
 from matplotlib.mlab import prctile_rank
-import numpy
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap as Basemap
 
 # cities colored by population rank.
@@ -16,9 +15,9 @@
 popranks = prctile_rank(pop,100)
 colors = []
 for rank in popranks:
- colors.append(p.cm.jet(float(rank)/100.))
+ colors.append(plt.cm.jet(float(rank)/100.))
 m.drawcoastlines()
 m.fillcontinents()
 m.scatter(x,y,25,colors,marker='o',faceted=False,zorder=10)
-p.title('City Locations colored by Population Rank')
-p.show()
+plt.title('City Locations colored by Population Rank')
+plt.show()
Modified: trunk/toolkits/basemap/examples/quiver_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/quiver_demo.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/quiver_demo.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,7 +1,6 @@
 from mpl_toolkits.basemap import Basemap
-import numpy
-from pylab import show, title, arange, meshgrid, cm, figure, \
- colorbar, axes, gca, reshape, quiverkey
+import numpy as np
+import matplotlib.pyplot as plt
 
 # read in data.
 file = open('fcover.dat','r')
@@ -13,12 +12,12 @@
 ul.append(float(l[0]))
 vl.append(float(l[1]))
 pl.append(float(l[2]))
-u = reshape(numpy.array(ul,numpy.float32),(nlats,nlons))
-v = reshape(numpy.array(vl,numpy.float32),(nlats,nlons))
-p = reshape(numpy.array(pl,numpy.float32),(nlats,nlons))
-lats1 = -90.+dellat*arange(nlats)
-lons1 = -180.+dellon*arange(nlons)
-lons, lats = meshgrid(lons1, lats1)
+u = np.reshape(np.array(ul,np.float32),(nlats,nlons))
+v = np.reshape(np.array(vl,np.float32),(nlats,nlons))
+p = np.reshape(np.array(pl,np.float32),(nlats,nlons))
+lats1 = -90.+dellat*np.arange(nlats)
+lons1 = -180.+dellon*np.arange(nlons)
+lons, lats = np.meshgrid(lons1, lats1)
 
 # plot vectors in geographical (lat/lon) coordinates.
 
@@ -26,32 +25,32 @@
 m = Basemap(lon_0=-135,boundinglat=25,
 resolution='c',area_thresh=10000.,projection='npstere')
 # create a figure, add an axes.
-fig=figure(figsize=(8,8))
+fig=plt.figure(figsize=(8,8))
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # rotate wind vectors to map projection coordinates.
 # (also compute native map projections coordinates of lat/lon grid)
 # only do Northern Hemisphere.
 urot,vrot,x,y = m.rotate_vector(u[36:,:],v[36:,:],lons[36:,:],lats[36:,:],returnxy=True)
 # plot filled contours over map.
-cs = m.contourf(x,y,p[36:,:],15,cmap=cm.jet)
+cs = m.contourf(x,y,p[36:,:],15,cmap=plt.cm.jet)
 # plot wind vectors over map.
 Q = m.quiver(x,y,urot,vrot) #or specify, e.g., width=0.003, scale=400)
-qk = quiverkey(Q, 0.95, 1.05, 25, '25 m/s', labelpos='W')
-cax = axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes.
-colorbar(cax=cax) # draw colorbar
-axes(ax) # make the original axes current again
+qk = plt.quiverkey(Q, 0.95, 1.05, 25, '25 m/s', labelpos='W')
+cax = plt.axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
 m.drawcoastlines()
 m.drawcountries()
 # draw parallels
 delat = 20.
-circles = arange(0.,90.+delat,delat).tolist()+\
- arange(-delat,-90.-delat,-delat).tolist()
+circles = np.arange(0.,90.+delat,delat).tolist()+\
+ np.arange(-delat,-90.-delat,-delat).tolist()
 m.drawparallels(circles,labels=[1,1,1,1])
 # draw meridians
 delon = 45.
-meridians = arange(-180,180,delon)
+meridians = np.arange(-180,180,delon)
 m.drawmeridians(meridians,labels=[1,1,1,1])
-title('Surface Winds Winds and Pressure (lat-lon grid)',y=1.075)
+plt.title('Surface Winds Winds and Pressure (lat-lon grid)',y=1.075)
 
 # plot vectors in map projection coordinates.
 
@@ -62,30 +61,30 @@
 # and interpolation).
 nxv = 41; nyv = 41
 nxp = 101; nyp = 101
-spd = numpy.sqrt(u**2+v**2)
+spd = np.sqrt(u**2+v**2)
 udat, vdat, xv, yv = m.transform_vector(u,v,lons1,lats1,nxv,nyv,returnxy=True)
 pdat, xp, yp = m.transform_scalar(p,lons1,lats1,nxp,nyp,returnxy=True)
 # create a figure, add an axes.
-fig=figure(figsize=(8,8))
+fig=plt.figure(figsize=(8,8))
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # plot image over map
-im = m.imshow(pdat,cm.jet)
+im = m.imshow(pdat,plt.cm.jet)
 # plot wind vectors over map.
 Q = m.quiver(xv,yv,udat,vdat) #or specify, e.g., width=0.003, scale=400)
-qk = quiverkey(Q, 0.95, 1.05, 25, '25 m/s', labelpos='W')
-cax = axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes.
-colorbar(cax=cax) # draw colorbar
-axes(ax) # make the original axes current again
+qk = plt.quiverkey(Q, 0.95, 1.05, 25, '25 m/s', labelpos='W')
+cax = plt.axes([0.875, 0.1, 0.05, 0.7]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
 m.drawcoastlines()
 m.drawcountries()
 # draw parallels
 delat = 20.
-circles = arange(0.,90.+delat,delat).tolist()+\
- arange(-delat,-90.-delat,-delat).tolist()
+circles = np.arange(0.,90.+delat,delat).tolist()+\
+ np.arange(-delat,-90.-delat,-delat).tolist()
 m.drawparallels(circles,labels=[1,1,1,1])
 # draw meridians
 delon = 45.
-meridians = arange(-180,180,delon)
+meridians = np.arange(-180,180,delon)
 m.drawmeridians(meridians,labels=[1,1,1,1])
-title('Surface Winds Winds and Pressure (projection grid)',y=1.075)
-show()
+plt.title('Surface Winds Winds and Pressure (projection grid)',y=1.075)
+plt.show()
Modified: trunk/toolkits/basemap/examples/randompoints.py
===================================================================
--- trunk/toolkits/basemap/examples/randompoints.py	2008年05月19日 19:09:35 UTC (rev 5195)
+++ trunk/toolkits/basemap/examples/randompoints.py	2008年05月20日 11:52:12 UTC (rev 5196)
@@ -1,4 +1,5 @@
-from pylab import show, title, arange, figure, title, arccos, pi, cm, text
+import numpy as np
+import matplotlib.pyplot as plt
 from matplotlib.colors import rgb2hex
 from mpl_toolkits.basemap import Basemap
 from numpy.random import uniform
@@ -18,16 +19,16 @@
 v = uniform(0.,1.,size=npts)
 z = uniform(0,100,size=npts)
 lons = 360.*u
-lats = (180./pi)*arccos(2*v-1) - 90.
+lats = (180./np.pi)*np.arccos(2*v-1) - 90.
 # transform lons and lats to map coordinates.
 x,y = m(lons,lats)
 # plot them as filled circles on the map.
 # first, create a figure.
-fig=figure()
+fig=plt.figure()
 # draw colored markers.
 # use zorder=10 to make sure markers are drawn last.
 # (otherwise they are covered up when continents are filled)
-#m.scatter(x,y,25,z,cmap=cm.jet,marker='o',faceted=False,zorder=10) 
+#m.scatter(x,y,25,z,cmap=plt.cm.jet,marker='o',faceted=False,zorder=10) 
 # create a list of strings containing z values
 # or, plot actual numbers as color-coded text strings.
 zn = [ '%2i' % zz for zz in z ]
@@ -35,8 +36,8 @@
 for numstr,zval,xpt,ypt in zip(zn,z,x,y):
 # only plot values inside map region.
 if xpt > m.xmin and xpt < m.xmax and ypt > m.ymin and ypt < m.ymax:
- hexcolor = rgb2hex(cm.jet(zval/100.)[:3])
- text(xpt,ypt,numstr,fontsize=9,weight='bold',color=hexcolor)
+ hexcolor = rgb2hex(plt.cm.jet(zval/100.)[:3])
+ plt.text(xpt,ypt,numstr,fontsize=9,weight='bold',color=hexcolor)
 # draw coasts and fill continents/lakes.
 m.drawcoastlines(linewidth=0.5)
 m.fillcontinents(color='coral',lake_color='aqua')
@@ -44,11 +45,11 @@
 m.drawmapboundary(fill_color='aqua')
 # draw parallels and meridians.
 delat = 20.
-circles = arange(0.,90.,delat).tolist()+\
- arange(-delat,-90,-delat).tolist()
+circles = np.arange(0.,90.,delat).tolist()+\
+ np.arange(-delat,-90,-delat).tolist()
 m.drawparallels(circles)
 delon = 45.
-meridians = arange(0,360,delon)
+meridians = np.arange(0,360,delon)
 m.drawmeridians(meridians,labels=[1,1,1,1])
-title('Random Points',y=1.075)
-show()
+plt.title('Random Points',y=1.075)
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年05月20日 12:22:22
Revision: 5197
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5197&view=rev
Author: jswhit
Date: 2008年05月20日 05:22:09 -0700 (2008年5月20日)
Log Message:
-----------
more examples updated to numpy/pyplot namespace
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/ccsm_popgrid.py
 trunk/toolkits/basemap/examples/fillstates.py
 trunk/toolkits/basemap/examples/garp.py
 trunk/toolkits/basemap/examples/hurrtracks.py
 trunk/toolkits/basemap/examples/panelplot.py
 trunk/toolkits/basemap/examples/plot_tissot.py
 trunk/toolkits/basemap/examples/plotprecip.py
 trunk/toolkits/basemap/examples/plotsst.py
 trunk/toolkits/basemap/examples/pnganim.py
 trunk/toolkits/basemap/examples/polarmaps.py
 trunk/toolkits/basemap/examples/setwh.py
 trunk/toolkits/basemap/examples/show_colormaps.py
 trunk/toolkits/basemap/examples/testgdal.py
Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py
===================================================================
--- trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -20,10 +20,10 @@
 
 POP grids are used extensively locally in oceanographic and ice models.
 """
-import pylab as pl
 from matplotlib import rcParams
-from numpy import ma as MA
-import numpy as N
+from numpy import ma 
+import numpy as np
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap, NetCDFFile
 
 # read in data from netCDF file.
@@ -36,17 +36,17 @@
 fpin.close()
 
 # make longitudes monotonically increasing.
-tlon = N.where(N.greater_equal(tlon,min(tlon[:,0])),tlon-360,tlon)
+tlon = np.where(np.greater_equal(tlon,min(tlon[:,0])),tlon-360,tlon)
 
 # stack grids side-by-side (in longitiudinal direction), so
 # any range of longitudes may be plotted on a world map.
-tlon = N.concatenate((tlon,tlon+360),1)
-tlat = N.concatenate((tlat,tlat),1)
-temp = MA.concatenate((temp,temp),1)
+tlon = np.concatenate((tlon,tlon+360),1)
+tlat = np.concatenate((tlat,tlat),1)
+temp = ma.concatenate((temp,temp),1)
 tlon = tlon-360.
 
-pl.figure(figsize=(6,8))
-pl.subplot(2,1,1)
+plt.figure(figsize=(6,8))
+plt.subplot(2,1,1)
 # subplot 1 just shows POP grid cells.
 map = Basemap(projection='merc', lat_ts=20, llcrnrlon=-180, \
 urcrnrlon=180, llcrnrlat=-84, urcrnrlat=84, resolution='c')
@@ -55,22 +55,22 @@
 map.fillcontinents(color='white')
 
 x, y = map(tlon,tlat)
-im = map.pcolor(x,y,MA.masked_array(N.zeros(temp.shape,'f'), temp.mask),\
- shading='faceted',cmap=pl.cm.cool,vmin=0,vmax=0)
+im = map.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),\
+ shading='faceted',cmap=plt.cm.cool,vmin=0,vmax=0)
 # disclaimer: these are not really the grid cells because of the
 # way pcolor interprets the x and y args.
-pl.title('(A) CCSM POP Grid Cells')
+plt.title('(A) CCSM POP Grid Cells')
 
 # subplot 2 is a contour plot of surface temperature from the
 # CCSM ocean model.
-pl.subplot(2,1,2)
+plt.subplot(2,1,2)
 map.drawcoastlines()
 map.fillcontinents(color='white')
 
 CS1 = map.contourf(x,y,temp,15)
 CS2 = map.contour(x,y,temp,15,colors='black',linewidths=0.5)
-pl.title('(B) Surface Temp contours on POP Grid')
+plt.title('(B) Surface Temp contours on POP Grid')
 
-pl.show()
-#pl.savefig('ccsm_popgrid.ps')
+plt.show()
+#plt.savefig('ccsm_popgrid.ps')
 
Modified: trunk/toolkits/basemap/examples/fillstates.py
===================================================================
--- trunk/toolkits/basemap/examples/fillstates.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/fillstates.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,5 +1,5 @@
-import pylab as p
-import numpy
+import numpy as np
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap as Basemap
 from matplotlib.colors import rgb2hex
 from matplotlib.patches import Polygon
@@ -68,7 +68,7 @@
 # choose a color for each state based on population density.
 colors={}
 statenames=[]
-cmap = p.cm.hot # use 'hot' colormap
+cmap = plt.cm.hot # use 'hot' colormap
 vmin = 0; vmax = 450 # set range.
 print m.states_info[0].keys()
 for shapedict in m.states_info:
@@ -79,10 +79,10 @@
 # calling colormap with value between 0 and 1 returns
 # rgba value. Invert color range (hot colors are high
 # population), take sqrt root to spread out colors more.
- colors[statename] = cmap(1.-p.sqrt((pop-vmin)/(vmax-vmin)))[:3]
+ colors[statename] = cmap(1.-np.sqrt((pop-vmin)/(vmax-vmin)))[:3]
 statenames.append(statename)
 # cycle through state names, color each one.
-ax = p.gca() # get current axes instance
+ax = plt.gca() # get current axes instance
 for nshape,seg in enumerate(m.states):
 # skip DC and Puerto Rico.
 if statenames[nshape] not in ['District of Columbia','Puerto Rico']:
@@ -90,7 +90,7 @@
 poly = Polygon(seg,facecolor=color,edgecolor=color)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(numpy.arange(25,65,20),labels=[1,0,0,0])
-m.drawmeridians(numpy.arange(-120,-40,20),labels=[0,0,0,1])
-p.title('Filling State Polygons by Population Density')
-p.show()
+m.drawparallels(np.arange(25,65,20),labels=[1,0,0,0])
+m.drawmeridians(np.arange(-120,-40,20),labels=[0,0,0,1])
+plt.title('Filling State Polygons by Population Density')
+plt.show()
Modified: trunk/toolkits/basemap/examples/garp.py
===================================================================
--- trunk/toolkits/basemap/examples/garp.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/garp.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,5 +1,6 @@
 from mpl_toolkits.basemap import Basemap
-from pylab import title, show, arange, pi
+import numpy as np
+import matplotlib.pyplot as plt
 
 # the shortest route from the center of the map
 # to any other point is a straight line in the azimuthal
@@ -30,11 +31,11 @@
 m.drawcoastlines(linewidth=0.5)
 m.fillcontinents(color='coral',lake_color='aqua')
 # 20 degree graticule.
-m.drawparallels(arange(-80,81,20))
-m.drawmeridians(arange(-180,180,20))
+m.drawparallels(np.arange(-80,81,20))
+m.drawmeridians(np.arange(-180,180,20))
 # draw a black dot at the center.
 xpt, ypt = m(lon_0, lat_0)
 m.plot([xpt],[ypt],'ko') 
 # draw the title.
-title('The World According to Garp in '+location)
-show()
+plt.title('The World According to Garp in '+location)
+plt.show()
Modified: trunk/toolkits/basemap/examples/hurrtracks.py
===================================================================
--- trunk/toolkits/basemap/examples/hurrtracks.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/hurrtracks.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,16 +1,17 @@
 """
 draw Atlantic Hurricane Tracks for storms that reached Cat 4 or 5.
 part of the track for which storm is cat 4 or 5 is shown red.
-ESRI shapefile data from http://www.nationalatlas.gov/atlasftp.html
+ESRI shapefile data from http://www.nationalatlas.gov/atlasftplt.html
 """
-import pylab as p
+import numpy as np
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap as Basemap
-# Lambert Conformal Conic map.
+# Lambert Conformal Conic maplt.
 m = Basemap(llcrnrlon=-100.,llcrnrlat=0.,urcrnrlon=-20.,urcrnrlat=57.,
 projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60.,
 resolution ='l',area_thresh=1000.)
 # create figure.
-fig=p.figure()
+fig=plt.figure()
 # read shapefile.
 shp_info = m.readshapefile('huralll020','hurrtracks',drawbounds=False)
 print shp_info
@@ -32,15 +33,15 @@
 xx,yy = zip(*shape)
 # show part of track where storm > Cat 4 as thick red.
 if cat in ['H4','H5']: 
- p.plot(xx,yy,linewidth=1.5,color='r')
+ plt.plot(xx,yy,linewidth=1.5,color='r')
 elif cat in ['H1','H2','H3']:
- p.plot(xx,yy,color='k')
+ plt.plot(xx,yy,color='k')
 # draw coastlines, meridians and parallels.
 m.drawcoastlines()
 m.drawcountries()
 m.drawmapboundary(fill_color='#99ffff')
 m.fillcontinents(color='#cc9966',lake_color='#99ffff')
-m.drawparallels(p.arange(10,70,20),labels=[1,1,0,0])
-m.drawmeridians(p.arange(-100,0,20),labels=[0,0,0,1])
-p.title('Atlantic Hurricane Tracks (Storms Reaching Category 4, 1851-2004)')
-p.show()
+m.drawparallels(np.arange(10,70,20),labels=[1,1,0,0])
+m.drawmeridians(np.arange(-100,0,20),labels=[0,0,0,1])
+plt.title('Atlantic Hurricane Tracks (Storms Reaching Category 4, 1851-2004)')
+plt.show()
Modified: trunk/toolkits/basemap/examples/panelplot.py
===================================================================
--- trunk/toolkits/basemap/examples/panelplot.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/panelplot.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,14 +1,16 @@
 from mpl_toolkits.basemap import Basemap
 from matplotlib import rcParams
 from matplotlib.ticker import MultipleLocator
-import pylab as P
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
 
 
 # read in data on lat/lon grid.
-hgt = P.load('500hgtdata.gz')
-lons = P.load('500hgtlons.gz')
-lats = P.load('500hgtlats.gz')
-lons, lats = P.meshgrid(lons, lats)
+hgt = mlab.load('500hgtdata.gz')
+lons = mlab.load('500hgtlons.gz')
+lats = mlab.load('500hgtlats.gz')
+lons, lats = np.meshgrid(lons, lats)
 
 # Example to show how to make multi-panel plots.
 
@@ -18,29 +20,29 @@
 rcParams['figure.subplot.wspace'] = 0.5 # more width between subplots
 
 # create new figure
-fig=P.figure()
+fig=plt.figure()
 # panel 1
 mnh = Basemap(lon_0=-105,boundinglat=20.,
 resolution='c',area_thresh=10000.,projection='nplaea')
 xnh,ynh = mnh(lons,lats)
 ax = fig.add_subplot(211)
 CS = mnh.contour(xnh,ynh,hgt,15,linewidths=0.5,colors='k')
-CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.Spectral)
+CS = mnh.contourf(xnh,ynh,hgt,15,cmap=plt.cm.Spectral)
 # colorbar on bottom.
 pos = ax.get_position()
 l, b, w, h = pos.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
+cax = plt.axes([l, b-0.05, w, 0.025]) # setup colorbar axes
+plt.colorbar(cax=cax, orientation='horizontal',ticks=CS.levels[0::4]) # draw colorbar
+plt.axes(ax) # make the original axes current again
 mnh.drawcoastlines(linewidth=0.5)
 delat = 30.
-circles = P.arange(0.,90.,delat).tolist()+\
- P.arange(-delat,-90,-delat).tolist()
+circles = np.arange(0.,90.,delat).tolist()+\
+ np.arange(-delat,-90,-delat).tolist()
 mnh.drawparallels(circles,labels=[1,0,0,0])
 delon = 45.
-meridians = P.arange(0,360,delon)
+meridians = np.arange(0,360,delon)
 mnh.drawmeridians(meridians,labels=[1,0,0,1])
-P.title('NH 500 hPa Height (cm.Spectral)')
+plt.title('NH 500 hPa Height (cm.Spectral)')
 
 # panel 2
 msh = Basemap(lon_0=-105,boundinglat=-20.,
@@ -48,17 +50,17 @@
 xsh,ysh = msh(lons,lats)
 ax = fig.add_subplot(212)
 CS = msh.contour(xsh,ysh,hgt,15,linewidths=0.5,colors='k')
-CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.Spectral)
+CS = msh.contourf(xsh,ysh,hgt,15,cmap=plt.cm.Spectral)
 # colorbar on bottom.
 pos = ax.get_position()
 l, b, w, h = pos.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
+cax = plt.axes([l, b-0.05, w, 0.025]) # setup colorbar axes
+plt.colorbar(cax=cax,orientation='horizontal',ticks=MultipleLocator(320)) # draw colorbar
+plt.axes(ax) # make the original axes current again
 msh.drawcoastlines(linewidth=0.5)
 msh.drawparallels(circles,labels=[1,0,0,0])
 msh.drawmeridians(meridians,labels=[1,0,0,1])
-P.title('SH 500 hPa Height (cm.Spectral)')
+plt.title('SH 500 hPa Height (cm.Spectral)')
 
 # 2-panel plot, oriented horizontally, colorbar on right.
 
@@ -68,33 +70,33 @@
 rcParams['figure.subplot.top'] = 0.85
 
 # panel 1
-fig = P.figure()
+fig = plt.figure()
 ax = fig.add_subplot(121)
 CS = mnh.contour(xnh,ynh,hgt,15,linewidths=0.5,colors='k')
-CS = mnh.contourf(xnh,ynh,hgt,15,cmap=P.cm.RdBu)
+CS = mnh.contourf(xnh,ynh,hgt,15,cmap=plt.cm.RdBu)
 # colorbar on right
 pos = ax.get_position()
 l, b, w, h = pos.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
+cax = plt.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
+plt.colorbar(cax=cax, ticks=MultipleLocator(160), format='%4i') # draw colorbar
+plt.axes(ax) # make the original axes current again
 mnh.drawcoastlines(linewidth=0.5)
 mnh.drawparallels(circles,labels=[1,0,0,0])
 mnh.drawmeridians(meridians,labels=[1,0,0,1])
-P.title('NH 500 hPa Height (cm.RdBu)')
+plt.title('NH 500 hPa Height (cm.RdBu)')
 
 # panel 2
 ax = fig.add_subplot(122)
 CS = msh.contour(xsh,ysh,hgt,15,linewidths=0.5,colors='k')
-CS = msh.contourf(xsh,ysh,hgt,15,cmap=P.cm.RdBu)
+CS = msh.contourf(xsh,ysh,hgt,15,cmap=plt.cm.RdBu)
 # colorbar on right.
 pos = ax.get_position()
 l, b, w, h = pos.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
+cax = plt.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
+plt.colorbar(cax=cax, ticks=MultipleLocator(160), format='%4i') # draw colorbar
+plt.axes(ax) # make the original axes current again
 msh.drawcoastlines(linewidth=0.5)
 msh.drawparallels(circles,labels=[1,0,0,0])
 msh.drawmeridians(meridians,labels=[1,0,0,1])
-P.title('SH 500 hPa Height (cm.RdBu)')
-P.show()
+plt.title('SH 500 hPa Height (cm.RdBu)')
+plt.show()
Modified: trunk/toolkits/basemap/examples/plot_tissot.py
===================================================================
--- trunk/toolkits/basemap/examples/plot_tissot.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/plot_tissot.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,4 +1,5 @@
-import pylab as p
+import numpy as np
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap as Basemap
 from matplotlib.patches import Polygon
 
@@ -13,44 +14,44 @@
 # adapted from http://www.perrygeo.net/wordpress/?p=4
 
 # create new figure
-fig=p.figure()
+fig=plt.figure()
 m = Basemap(llcrnrlon=-180,llcrnrlat=-80,urcrnrlon=180,urcrnrlat=80,
 projection='cyl')
 shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
-ax = p.gca()
+ax = plt.gca()
 for nshape,seg in enumerate(m.tissot):
 poly = Polygon(seg,facecolor='green',zorder=10)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(p.arange(-90,91,30),labels=[1,0,0,0])
-m.drawmeridians(p.arange(-180,180,60),labels=[0,0,0,1])
+m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
+m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
 m.drawcoastlines()
 m.fillcontinents()
-p.title('Tissot Diagram - Cylindrical Equal Area')
+plt.title('Tissot Diagram - Cylindrical Equal Area')
 print 'plot Cylindrical Equidistant Equal Area Tissot diagram ...'
 
 # create new figure
-fig=p.figure()
+fig=plt.figure()
 m = Basemap(llcrnrlon=-180,llcrnrlat=-70,urcrnrlon=180,urcrnrlat=70,
 projection='merc',lat_ts=20)
 shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
-ax = p.gca()
+ax = plt.gca()
 for nshape,seg in enumerate(m.tissot):
 poly = Polygon(seg,facecolor='green',zorder=10)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(p.arange(-90,91,30),labels=[1,0,0,0])
-m.drawmeridians(p.arange(-180,180,60),labels=[0,0,0,1])
+m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
+m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1])
 m.drawcoastlines()
 m.fillcontinents()
-p.title('Tissot Diagram - Mercator Conformal')
+plt.title('Tissot Diagram - Mercator Conformal')
 print 'plot Mercator Conformal Tissot diagram ...'
 
 # create new figure
-fig=p.figure()
+fig=plt.figure()
 m = Basemap(lon_0=-60,lat_0=45,projection='ortho')
 shp_info = m.readshapefile('tissot','tissot',drawbounds=False)
-ax = p.gca()
+ax = plt.gca()
 for nshape,seg in enumerate(m.tissot):
 xx,yy = zip(*seg)
 if max(xx) < 1.e20 and max(yy) < 1.e20:
@@ -58,42 +59,42 @@
 ax.add_patch(poly)
 m.drawcoastlines()
 m.fillcontinents()
-m.drawparallels(p.arange(-90,91,30))
-m.drawmeridians(p.arange(-180,180,30))
-p.title('Tissot Diagram - Orthographic')
+m.drawparallels(np.arange(-90,91,30))
+m.drawmeridians(np.arange(-180,180,30))
+plt.title('Tissot Diagram - Orthographic')
 m.drawmapboundary()
-p.gca().set_frame_on(True)
+plt.gca().set_frame_on(True)
 print 'plot Orthographic Tissot diagram ...'
 
 # create new figure
-fig=p.figure()
+fig=plt.figure()
 m = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='npstere')
 shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
-ax = p.gca()
+ax = plt.gca()
 for nshape,seg in enumerate(m.tissot):
 poly = Polygon(seg,facecolor='green',zorder=10)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(p.arange(-90,91,30),labels=[1,0,0,0])
-m.drawmeridians(p.arange(-180,180,30),labels=[0,0,0,1])
+m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
+m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1])
 m.drawcoastlines()
 m.fillcontinents()
-p.title('Tissot Diagram - North Polar Stereographic Conformal')
+plt.title('Tissot Diagram - North Polar Stereographic Conformal')
 print 'plot North Polar Stereographic Conformal Tissot diagram ...'
 
 # create new figure
-fig=p.figure()
+fig=plt.figure()
 m = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='nplaea')
 shp_info = m.readshapefile('tissot','tissot',drawbounds=True)
-ax = p.gca()
+ax = plt.gca()
 for nshape,seg in enumerate(m.tissot):
 poly = Polygon(seg,facecolor='green',zorder=10)
 ax.add_patch(poly)
 # draw meridians and parallels.
-m.drawparallels(p.arange(-90,91,30),labels=[1,0,0,0])
-m.drawmeridians(p.arange(-180,180,30),labels=[0,0,0,1])
+m.drawparallels(np.arange(-90,91,30),labels=[1,0,0,0])
+m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1])
 m.drawcoastlines()
 m.fillcontinents()
-p.title('Tissot Diagram - North Polar Lambert Azimuthal Equal Area')
+plt.title('Tissot Diagram - North Polar Lambert Azimuthal Equal Area')
 print 'plot North Polar Lambert Azimuthal Equal Area Tissot diagram ...'
-p.show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/plotprecip.py
===================================================================
--- trunk/toolkits/basemap/examples/plotprecip.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/plotprecip.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,5 +1,7 @@
 from mpl_toolkits.basemap import Basemap, cm, NetCDFFile
-import pylab, copy
+import numpy as np
+import matplotlib.pyplot as plt
+import copy
 from matplotlib import rcParams
 
 # make tick labels smaller
@@ -29,20 +31,20 @@
 llcrnrlon=loncorners[0],urcrnrlon=loncorners[2],\
 rsphere=6371200.,resolution='l',area_thresh=10000)
 # create figure
-fig = pylab.figure(figsize=(6,8.5))
-pylab.subplot(211)
-ax = pylab.gca()
+fig = plt.figure(figsize=(6,8.5))
+plt.subplot(211)
+ax = plt.gca()
 # draw coastlines, state and country boundaries, edge of map.
 m.drawcoastlines()
 m.drawstates()
 m.drawcountries()
 # draw parallels.
 delat = 10.0
-parallels = pylab.arange(0.,90,delat)
+parallels = np.arange(0.,90,delat)
 m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
 # draw meridians
 delon = 10.
-meridians = pylab.arange(180.,360.,delon)
+meridians = np.arange(180.,360.,delon)
 m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
 ny = data.shape[0]; nx = data.shape[1]
 lons, lats = m.makegrid(nx, ny) # get lat/lons of ny by nx evenly space grid.
@@ -53,15 +55,15 @@
 # new axis for colorbar.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
-cax = pylab.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
+cax = plt.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
 # draw colorbar.
-pylab.colorbar(cs, cax, format='%g', ticks=clevs, drawedges=False) 
-pylab.axes(ax) # make the original axes current again
+plt.colorbar(cs, cax, format='%g', ticks=clevs, drawedges=False) 
+plt.axes(ax) # make the original axes current again
 # plot title
-pylab.title(plottitle+'- contourf',fontsize=10)
+plt.title(plottitle+'- contourf',fontsize=10)
 
-pylab.subplot(212)
-ax = pylab.gca()
+plt.subplot(212)
+ax = plt.gca()
 # draw coastlines, state and country boundaries, edge of map.
 m.drawcoastlines()
 m.drawstates()
@@ -79,15 +81,15 @@
 # new axis for colorbar.
 pos = ax.get_position()
 l, b, w, h = pos.bounds
-cax = pylab.axes([l+w+0.025, b, 0.025, h]) # setup colorbar axes
+cax = plt.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
 # from highly nonuniform colormap)
-pylab.colorbar(im2, cax, format='%d') # draw colorbar
-pylab.axes(ax) # make the original axes current again
+plt.colorbar(im2, cax, format='%d') # draw colorbar
+plt.axes(ax) # make the original axes current again
 # reset colorbar tick labels (hack to get
-cax.set_yticks(pylab.linspace(0,1,len(clevs)))
+cax.set_yticks(np.linspace(0,1,len(clevs)))
 cax.set_yticklabels(['%g' % clev for clev in clevs])
 # plot title
-pylab.title(plottitle+' - imshow',fontsize=10)
-pylab.show() # display onscreen.
+plt.title(plottitle+' - imshow',fontsize=10)
+plt.show() # display onscreen.
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/plotsst.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,5 +1,7 @@
 from mpl_toolkits.basemap import Basemap, NetCDFFile
-import pylab, numpy, sys
+import numpy as np
+import matplotlib.pyplot as plt
+import sys
 # read in sea-surface temperature and ice data
 # can be a local file, a URL for a remote opendap dataset,
 # or (if PyNIO is installed) a GRIB or HDF file.
@@ -25,29 +27,29 @@
 delat = lats[1]-lats[0]
 lons = (lons - 0.5*delon).tolist()
 lons.append(lons[-1]+delon)
-lons = numpy.array(lons,numpy.float64)
+lons = np.array(lons,np.float64)
 lats = (lats - 0.5*delat).tolist()
 lats.append(lats[-1]+delat)
-lats = numpy.array(lats,numpy.float64)
+lats = np.array(lats,np.float64)
 # create Basemap instance for mollweide projection.
 # coastlines not used, so resolution set to None to skip
 # continent processing (this speeds things up a bit)
 #m = Basemap(projection='ortho',lon_0=-110,lat_0=20,resolution=None)
 m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None)
 # compute map projection coordinates of grid.
-x, y = m(*numpy.meshgrid(lons, lats))
+x, y = m(*np.meshgrid(lons, lats))
 # draw line around map projection limb.
 # color background of map projection region.
 # missing values over land will show up this color.
 m.drawmapboundary(fill_color='0.3')
 # plot ice, then with pcolor
-im1 = m.pcolor(x,y,sst,shading='flat',cmap=pylab.cm.jet)
-im2 = m.pcolor(x,y,ice,shading='flat',cmap=pylab.cm.gist_gray)
+im1 = m.pcolor(x,y,sst,shading='flat',cmap=plt.cm.jet)
+im2 = m.pcolor(x,y,ice,shading='flat',cmap=plt.cm.gist_gray)
 # draw parallels and meridians, but don't bother labelling them.
-m.drawparallels(numpy.arange(-90.,120.,30.))
-m.drawmeridians(numpy.arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
 # draw horizontal colorbar.
-pylab.colorbar(im1,orientation='horizontal')
+plt.colorbar(im1,orientation='horizontal')
 # display the plot with a title.
-pylab.title('SST and ICE analysis for %s'%date)
-pylab.show()
+plt.title('SST and ICE analysis for %s'%date)
+plt.show()
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/pnganim.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -4,8 +4,9 @@
 
 # reads data over http - needs an active internet connection.
 
-import numpy
-import pylab
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
 from numpy import ma
 import datetime, sys, time, subprocess
 from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
@@ -62,40 +63,40 @@
 vin = vdata[ntime1:ntime2+1,0,:,:] 
 datelabels = dates[ntime1:ntime2+1]
 # add cyclic points
-slp = numpy.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),numpy.float64)
+slp = np.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),np.float64)
 slp[:,:,0:-1] = slpin; slp[:,:,-1] = slpin[:,:,0]
-u = numpy.zeros((uin.shape[0],uin.shape[1],uin.shape[2]+1),numpy.float64)
+u = np.zeros((uin.shape[0],uin.shape[1],uin.shape[2]+1),np.float64)
 u[:,:,0:-1] = uin; u[:,:,-1] = uin[:,:,0]
-v = numpy.zeros((vin.shape[0],vin.shape[1],vin.shape[2]+1),numpy.float64)
+v = np.zeros((vin.shape[0],vin.shape[1],vin.shape[2]+1),np.float64)
 v[:,:,0:-1] = vin; v[:,:,-1] = vin[:,:,0]
-longitudes.append(360.); longitudes = numpy.array(longitudes)
+longitudes.append(360.); longitudes = np.array(longitudes)
 # make 2-d grid of lons, lats
-lons, lats = numpy.meshgrid(longitudes,latitudes)
+lons, lats = np.meshgrid(longitudes,latitudes)
 print 'min/max slp,u,v'
 print slp.min(), slp.max()
 print uin.min(), uin.max()
 print vin.min(), vin.max()
 print 'dates'
 print datelabels
-# make orthographic basemapylab.
+# make orthographic basemaplt.
 m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
-pylab.ion() # interactive mode on.
+plt.ion() # interactive mode on.
 uin = udata[ntime1:ntime2+1,0,:,:] 
 vin = vdata[ntime1:ntime2+1,0,:,:] 
 datelabels = dates[ntime1:ntime2+1]
-# make orthographic basemapylab.
+# make orthographic basemaplt.
 m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
-pylab.ion() # interactive mode on.
+plt.ion() # interactive mode on.
 # create figure, add axes (leaving room for colorbar on right)
-fig = pylab.figure()
+fig = plt.figure()
 ax = fig.add_axes([0.1,0.1,0.7,0.7])
 # set desired contour levels.
-clevs = numpy.arange(960,1061,5)
+clevs = np.arange(960,1061,5)
 # compute native x,y coordinates of grid.
 x, y = m(lons, lats)
 # define parallels and meridians to draw.
-parallels = numpy.arange(-80.,90,20.)
-meridians = numpy.arange(0.,360.,20.)
+parallels = np.arange(-80.,90,20.)
+meridians = np.arange(0.,360.,20.)
 # number of repeated frames at beginning and end is n1.
 nframe = 0; n1 = 10
 pos = ax.get_position()
@@ -104,42 +105,42 @@
 # parallels, meridians and title.
 for nt,date in enumerate(datelabels[1:]):
 CS = m.contour(x,y,slp[nt,:,:],clevs,linewidths=0.5,colors='k',animated=True)
- CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=pylab.cm.RdBu_r,animated=True)
+ CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=plt.cm.RdBu_r,animated=True)
 # plot wind vectors on lat/lon grid.
 # rotate wind vectors to map projection coordinates.
 #urot,vrot = m.rotate_vector(u[nt,:,:],v[nt,:,:],lons,lats)
- # plot wind vectors over mapylab.
+ # plot wind vectors over maplt.
 #Q = m.quiver(x,y,urot,vrot,scale=500) 
 # plot wind vectors on projection grid (looks better).
 # first, shift grid so it goes from -180 to 180 (instead of 0 to 360
- # in longitude). Otherwise, interpolation is messed upylab.
+ # in longitude). Otherwise, interpolation is messed uplt.
 ugrid,newlons = shiftgrid(180.,u[nt,:,:],longitudes,start=False)
 vgrid,newlons = shiftgrid(180.,v[nt,:,:],longitudes,start=False)
 # transform vectors to projection grid.
 urot,vrot,xx,yy = m.transform_vector(ugrid,vgrid,newlons,latitudes,51,51,returnxy=True,masked=True)
- # plot wind vectors over mapylab.
+ # plot wind vectors over maplt.
 Q = m.quiver(xx,yy,urot,vrot,scale=500)
 # make quiver key.
- qk = pylab.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
+ qk = plt.quiverkey(Q, 0.1, 0.1, 20, '20 m/s', labelpos='W')
 # draw coastlines, parallels, meridians, title.
 m.drawcoastlines(linewidth=1.5)
 m.drawparallels(parallels)
 m.drawmeridians(meridians)
- pylab.title('SLP and Wind Vectors '+date)
+ plt.title('SLP and Wind Vectors '+date)
 if nt == 0: # plot colorbar on a separate axes (only for first frame)
- cax = pylab.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
+ cax = plt.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
 fig.colorbar(CS,drawedges=True, cax=cax) # draw colorbar
 cax.text(0.0,-0.05,'mb')
- pylab.axes(ax) # reset current axes
- pylab.draw() # draw the plot
+ plt.axes(ax) # reset current axes
+ plt.draw() # draw the plot
 # save first and last frame n1 times 
 # (so gif animation pauses at beginning and end)
 if nframe == 0 or nt == slp.shape[0]-1:
 for n in range(n1):
- pylab.savefig('anim%03i'%nframe+'.png')
+ plt.savefig('anim%03i'%nframe+'.png')
 nframe = nframe + 1
 else:
- pylab.savefig('anim%03i'%nframe+'.png')
+ plt.savefig('anim%03i'%nframe+'.png')
 nframe = nframe + 1
 ax.clear() # clear the axes for the next plot.
 
Modified: trunk/toolkits/basemap/examples/polarmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/polarmaps.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/polarmaps.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -6,17 +6,18 @@
 # illustrates special-case polar-centric projections.
 
 from mpl_toolkits.basemap import Basemap
-from pylab import title, colorbar, show, axes, cm, load, arange, \
- figure, ravel, meshgrid
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
 
 # read in topo data (on a regular lat/lon grid)
 # longitudes go from 20 to 380.
-etopo = load('etopo20data.gz')
-lons = load('etopo20lons.gz')
-lats = load('etopo20lats.gz')
+etopo = mlab.load('etopo20data.gz')
+lons = mlab.load('etopo20lons.gz')
+lats = mlab.load('etopo20lats.gz')
 
 print 'min/max etopo20 data:'
-print min(ravel(etopo)),max(ravel(etopo))
+print etopo.min(),etopo.max()
 
 # these are the 4 polar projections
 projs = ['laea','stere','aeqd','ortho'] # short names
@@ -36,7 +37,7 @@
 lat_0 = 90.
 bounding_lat = 20.
 # loop over projections, one for each panel of the figure.
- fig = figure(figsize=(8,8))
+ fig = plt.figure(figsize=(8,8))
 npanel = 0
 for proj,projname in zip(projs,projnames):
 npanel = npanel + 1
@@ -53,18 +54,18 @@
 m = Basemap(boundinglat=bounding_lat,lon_0=lon_0,\
 resolution='c',area_thresh=10000.,projection=projection)
 # compute native map projection coordinates for lat/lon grid.
- x,y = m(*meshgrid(lons,lats))
+ x,y = m(*np.meshgrid(lons,lats))
 ax = fig.add_subplot(2,2,npanel)
 # make filled contour plot.
- cs = m.contourf(x,y,etopo,20,cmap=cm.jet)
+ cs = m.contourf(x,y,etopo,20,cmap=plt.cm.jet)
 # draw coastlines.
 m.drawcoastlines()
 # draw parallels and meridians.
- m.drawparallels(arange(-80.,90,20.))
- m.drawmeridians(arange(0.,360.,60.))
+ m.drawparallels(np.arange(-80.,90,20.))
+ m.drawmeridians(np.arange(0.,360.,60.))
 # draw boundary around map region.
 m.drawmapboundary()
 # draw title.
- title(hem+' Polar '+projname,y=1.05,fontsize=12)
+ plt.title(hem+' Polar '+projname,y=1.05,fontsize=12)
 print 'plotting '+hem+' Polar '+projname+' basemap ...'
-show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/setwh.py
===================================================================
--- trunk/toolkits/basemap/examples/setwh.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/setwh.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -2,7 +2,8 @@
 # to the Basemap constructor.
 
 from mpl_toolkits.basemap import Basemap
-from pylab import arange, show, title, figure
+import numpy as np
+import matplotlib.pyplot as plt
 
 # setup projection parameters
 lat_0 = 40.
@@ -10,14 +11,14 @@
 width = 6000000.
 height = 2.*width/3.
 delat = 25.
-circles = arange(0.,90.+delat,delat).tolist()+\
- arange(-delat,-90.-delat,-delat).tolist()
+circles = np.arange(0.,90.+delat,delat).tolist()+\
+ np.arange(-delat,-90.-delat,-delat).tolist()
 delon = 30.
-meridians = arange(10.,360.,delon)
+meridians = np.arange(10.,360.,delon)
 npanel = 0
 # plots of the US.
 projs = ['lcc','aeqd','aea','laea','eqdc','stere']
-fig = figure(figsize=(7,7))
+fig = plt.figure(figsize=(7,7))
 for proj in projs:
 m = Basemap(width=width,height=height,
 resolution='c',projection=proj,\
@@ -30,6 +31,6 @@
 m.drawstates()
 m.drawparallels(circles)
 m.drawmeridians(meridians)
- title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10)
+ plt.title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10)
 
-show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/show_colormaps.py
===================================================================
--- trunk/toolkits/basemap/examples/show_colormaps.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/show_colormaps.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -1,16 +1,17 @@
-import numpy, pylab
+import numpy as np
+import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import cm
-a=numpy.outer(numpy.arange(0,1,0.01),numpy.ones(10))
-pylab.figure(figsize=(10,7))
-pylab.subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99)
+a=np.outer(np.arange(0,1,0.01),np.ones(10))
+plt.figure(figsize=(10,7))
+plt.subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99)
 maps=[m for m in cm.datad.keys() if not m.endswith("_r")]
 maps.sort()
 l=len(maps)+1
 i=1
 for m in maps:
- pylab.subplot(1,l,i)
- pylab.axis("off")
- pylab.imshow(a,aspect='auto',cmap=cm.__dict__[m],origin="lower")
- pylab.title(m,rotation=90,fontsize=10)
+ plt.subplot(1,l,i)
+ plt.axis("off")
+ plt.imshow(a,aspect='auto',cmap=cm.__dict__[m],origin="lower")
+ plt.title(m,rotation=90,fontsize=10)
 i=i+1
-pylab.show()
+plt.show()
Modified: trunk/toolkits/basemap/examples/testgdal.py
===================================================================
--- trunk/toolkits/basemap/examples/testgdal.py	2008年05月20日 11:52:12 UTC (rev 5196)
+++ trunk/toolkits/basemap/examples/testgdal.py	2008年05月20日 12:22:09 UTC (rev 5197)
@@ -3,13 +3,14 @@
 gdal (http://gdal.maptools.org).
 
 Data files must be downloaded manually from USGS:
-http://edcftp.cr.usgs.gov/pub/data/DEM/250/D/denver-w.gz
-http://edcftp.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
+http://edcftplt.cr.usgs.gov/pub/data/DEM/250/D/denver-w.gz
+http://edcftplt.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
 """
 import gdal
 from mpl_toolkits.basemap import Basemap
 from gdalconst import *
-import pylab as p
+import numpy as np
+import matplotlib.pyplot as plt
 
 # download from 
 # http://edcftp.cr.usgs.gov/pub/data/DEM/250/D/denver-w.gz
@@ -26,17 +27,17 @@
 m = Basemap(llcrnrlon=llcrnrlon,llcrnrlat=llcrnrlat,urcrnrlon=urcrnrlon,urcrnrlat=urcrnrlat,projection='cyl')
 # create a figure, add an axes
 # (leaving room for a colorbar).
-fig = p.figure()
+fig = plt.figure()
 ax = fig.add_axes([0.1,0.1,0.75,0.75])
 # plot image from DEM over map.
 im = m.imshow(array,origin='upper')
 # make a colorbar.
-cax = p.axes([0.875, 0.1, 0.05, 0.75]) # setup colorbar axes.
-p.colorbar(cax=cax) # draw colorbar
-p.axes(ax) # make the original axes current again
+cax = plt.axes([0.875, 0.1, 0.05, 0.75]) # setup colorbar axes.
+plt.colorbar(cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
 # draw meridians and parallels.
-m.drawmeridians(p.linspace(llcrnrlon+0.1,urcrnrlon-0.1,5),labels=[0,0,0,1],fmt='%4.2f')
-m.drawparallels(p.linspace(llcrnrlat+0.1,urcrnrlat-0.1,5),labels=[1,0,0,0],fmt='%4.2f')
+m.drawmeridians(np.linspace(llcrnrlon+0.1,urcrnrlon-0.1,5),labels=[0,0,0,1],fmt='%4.2f')
+m.drawparallels(np.linspace(llcrnrlat+0.1,urcrnrlat-0.1,5),labels=[1,0,0,0],fmt='%4.2f')
 # plot county boundaries from
 # http://edcftp.cr.usgs.gov/pub/data/nationalatlas/countyp020.tar.gz
 shp_info = m.readshapefile('countyp020','counties',drawbounds=True,linewidth=1.0)
@@ -46,6 +47,6 @@
 x,y = m(lons,lats)
 m.plot(x,y,'ko')
 for name,xx,yy in zip(names,x,y):
- p.text(xx+0.01,yy+0.01,name)
-p.title(gd.GetDescription()+' USGS DEM with county boundaries')
-p.show()
+ plt.text(xx+0.01,yy+0.01,name)
+plt.title(gd.GetDescription()+' USGS DEM with county boundaries')
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年05月31日 12:26:23
Revision: 5340
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5340&view=rev
Author: jswhit
Date: 2008年05月31日 05:26:21 -0700 (2008年5月31日)
Log Message:
-----------
replace "faceted=False" with "edgecolors='none' to suppress deprecation warning
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/plotcities.py
 trunk/toolkits/basemap/examples/randompoints.py
Modified: trunk/toolkits/basemap/examples/plotcities.py
===================================================================
--- trunk/toolkits/basemap/examples/plotcities.py	2008年05月30日 22:24:06 UTC (rev 5339)
+++ trunk/toolkits/basemap/examples/plotcities.py	2008年05月31日 12:26:21 UTC (rev 5340)
@@ -18,6 +18,6 @@
 colors.append(plt.cm.jet(float(rank)/100.))
 m.drawcoastlines()
 m.fillcontinents()
-m.scatter(x,y,25,colors,marker='o',faceted=False,zorder=10)
+m.scatter(x,y,25,colors,marker='o',edgecolors='none',zorder=10)
 plt.title('City Locations colored by Population Rank')
 plt.show()
Modified: trunk/toolkits/basemap/examples/randompoints.py
===================================================================
--- trunk/toolkits/basemap/examples/randompoints.py	2008年05月30日 22:24:06 UTC (rev 5339)
+++ trunk/toolkits/basemap/examples/randompoints.py	2008年05月31日 12:26:21 UTC (rev 5340)
@@ -28,7 +28,7 @@
 # draw colored markers.
 # use zorder=10 to make sure markers are drawn last.
 # (otherwise they are covered up when continents are filled)
-#m.scatter(x,y,25,z,cmap=plt.cm.jet,marker='o',faceted=False,zorder=10) 
+#m.scatter(x,y,25,z,cmap=plt.cm.jet,marker='o',edgecolors='none',zorder=10) 
 # create a list of strings containing z values
 # or, plot actual numbers as color-coded text strings.
 zn = [ '%2i' % zz for zz in z ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年05月31日 13:03:29
Revision: 5342
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5342&view=rev
Author: jswhit
Date: 2008年05月31日 06:03:28 -0700 (2008年5月31日)
Log Message:
-----------
use "import numpy.ma as ma" instead of "from numpy import ma"
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/ccsm_popgrid.py
 trunk/toolkits/basemap/examples/fcstmaps.py
 trunk/toolkits/basemap/examples/plotmap_masked.py
 trunk/toolkits/basemap/examples/pnganim.py
Modified: trunk/toolkits/basemap/examples/ccsm_popgrid.py
===================================================================
--- trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年05月31日 12:57:10 UTC (rev 5341)
+++ trunk/toolkits/basemap/examples/ccsm_popgrid.py	2008年05月31日 13:03:28 UTC (rev 5342)
@@ -21,7 +21,7 @@
 POP grids are used extensively locally in oceanographic and ice models.
 """
 from matplotlib import rcParams
-from numpy import ma 
+import numpy.ma as ma
 import numpy as np
 import matplotlib.pyplot as plt
 from mpl_toolkits.basemap import Basemap, NetCDFFile
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py	2008年05月31日 12:57:10 UTC (rev 5341)
+++ trunk/toolkits/basemap/examples/fcstmaps.py	2008年05月31日 13:03:28 UTC (rev 5342)
@@ -3,7 +3,7 @@
 import numpy as np
 import matplotlib.pyplot as plt
 import sys
-from numpy import ma
+import numpy.ma as ma
 import datetime
 from mpl_toolkits.basemap import Basemap, NetCDFFile, addcyclic, num2date
 
Modified: trunk/toolkits/basemap/examples/plotmap_masked.py
===================================================================
--- trunk/toolkits/basemap/examples/plotmap_masked.py	2008年05月31日 12:57:10 UTC (rev 5341)
+++ trunk/toolkits/basemap/examples/plotmap_masked.py	2008年05月31日 13:03:28 UTC (rev 5342)
@@ -6,7 +6,7 @@
 # (in this case the oceans)
 
 from mpl_toolkits.basemap import Basemap, shiftgrid
-from numpy import ma
+import numpy.ma as ma
 import numpy as np
 import matplotlib.pyplot as plt
 import matplotlib.mlab as mlab
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py	2008年05月31日 12:57:10 UTC (rev 5341)
+++ trunk/toolkits/basemap/examples/pnganim.py	2008年05月31日 13:03:28 UTC (rev 5342)
@@ -7,7 +7,7 @@
 import numpy as np
 import matplotlib.pyplot as plt
 import matplotlib.mlab as mlab
-from numpy import ma
+import numpy.ma as ma
 import datetime, sys, time, subprocess
 from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年06月05日 11:57:33
Revision: 5393
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5393&view=rev
Author: jswhit
Date: 2008年06月05日 04:57:31 -0700 (2008年6月05日)
Log Message:
-----------
adjust for new num2date defaults.
Modified Paths:
--------------
 trunk/toolkits/basemap/examples/fcstmaps.py
 trunk/toolkits/basemap/examples/pnganim.py
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py	2008年06月05日 01:18:55 UTC (rev 5392)
+++ trunk/toolkits/basemap/examples/fcstmaps.py	2008年06月05日 11:57:31 UTC (rev 5393)
@@ -37,7 +37,7 @@
 times = fcsttimes[0:6] # first 6 forecast times.
 ntimes = len(times)
 # convert times for datetime instances.
-fdates = num2date(times,fcsttimes.units)
+fdates = num2date(times,units=fcsttimes.units,calendar='standard')
 # make a list of YYYYMMDDHH strings.
 verifdates = [fdate.strftime('%Y%m%d%H') for fdate in fdates]
 # convert times to forecast hours.
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py	2008年06月05日 01:18:55 UTC (rev 5392)
+++ trunk/toolkits/basemap/examples/pnganim.py	2008年06月05日 11:57:31 UTC (rev 5393)
@@ -42,7 +42,7 @@
 longitudes = data.variables['lon'][:].tolist()
 times = data.variables['time']
 # convert numeric time values to datetime objects.
-fdates = num2date(times[:],times.units)
+fdates = num2date(times[:],units=times.units,calendar='standard')
 # put times in YYYYMMDDHH format.
 dates = [fdate.strftime('%Y%m%d%H') for fdate in fdates]
 if YYYYMMDDHH1 not in dates or YYYYMMDDHH2 not in dates:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <js...@us...> - 2008年07月11日 15:04:29
Revision: 5738
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5738&view=rev
Author: jswhit
Date: 2008年07月11日 08:04:22 -0700 (2008年7月11日)
Log Message:
-----------
don't need anymore
Removed Paths:
-------------
 trunk/toolkits/basemap/examples/tissot.dbf
 trunk/toolkits/basemap/examples/tissot.shp
 trunk/toolkits/basemap/examples/tissot.shx
Deleted: trunk/toolkits/basemap/examples/tissot.dbf
===================================================================
(Binary files differ)
Deleted: trunk/toolkits/basemap/examples/tissot.shp
===================================================================
(Binary files differ)
Deleted: trunk/toolkits/basemap/examples/tissot.shx
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /