From: <js...@us...> - 2008-02-15 16:01:10
|
Revision: 4973 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4973&view=rev Author: jswhit Date: 2008-02-15 08:01:05 -0800 (Fri, 15 Feb 2008) Log Message: ----------- added blue marble background Modified Paths: -------------- trunk/toolkits/basemap/examples/wiki_example.py Modified: trunk/toolkits/basemap/examples/wiki_example.py =================================================================== --- trunk/toolkits/basemap/examples/wiki_example.py 2008-02-15 15:47:46 UTC (rev 4972) +++ trunk/toolkits/basemap/examples/wiki_example.py 2008-02-15 16:01:05 UTC (rev 4973) @@ -35,6 +35,39 @@ x, y = map(lons*180./p.pi, lats*180./p.pi) # contour data over the map. cs = map.contour(x,y,wave+mean,15,linewidths=1.5) + +# as above, but use blue marble image as map background. +fig = p.figure() +map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l') +map.drawmapboundary() +map.drawmeridians(p.arange(0,360,30)) +map.drawparallels(p.arange(-90,90,30)) +# lat/lon coordinates of five cities. +lats=[40.02,32.73,38.55,48.25,17.29] +lons=[-105.16,-117.16,-77.00,-114.21,-88.10] +cities=['Boulder, CO','San Diego, CA', + 'Washington, DC','Whitefish, MT','Belize City, Belize'] +# compute the native map projection coordinates for cities. +x,y = map(lons,lats) +# plot filled circles at the locations of the cities. +map.plot(x,y,'yo') +# plot the names of those five cities. +for name,xpt,ypt in zip(cities,x,y): + p.text(xpt+50000,ypt+50000,name,fontsize=9,color='w') +# make up some data on a regular lat/lon grid. +nlats = 73; nlons = 145; delta = 2.*p.pi/(nlons-1) +lats = (0.5*p.pi-delta*p.indices((nlats,nlons))[0,:,:]) +lons = (delta*p.indices((nlats,nlons))[1,:,:]) +wave = 0.75*(p.sin(2.*lats)**8*p.cos(4.*lons)) +mean = 0.5*p.cos(2.*lats)*((p.sin(2.*lats))**2 + 2.) +# compute native map projection coordinates of lat/lon grid. +x, y = map(lons*180./p.pi, lats*180./p.pi) +# contour data over the map. +cs = map.contour(x,y,wave+mean,15,linewidths=1.5) +# draw blue marble image in background. +map.bluemarble() p.show() + #p.savefig('wiki_example.ps') + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-05-17 12:04:38
|
Revision: 5167 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5167&view=rev Author: jswhit Date: 2008-05-17 05:04:34 -0700 (Sat, 17 May 2008) Log Message: ----------- convert to pyplot/numpy namespace. Modified Paths: -------------- trunk/toolkits/basemap/examples/wiki_example.py Modified: trunk/toolkits/basemap/examples/wiki_example.py =================================================================== --- trunk/toolkits/basemap/examples/wiki_example.py 2008-05-17 11:52:15 UTC (rev 5166) +++ trunk/toolkits/basemap/examples/wiki_example.py 2008-05-17 12:04:34 UTC (rev 5167) @@ -1,5 +1,6 @@ from mpl_toolkits.basemap import Basemap -import pylab as p +import matplotlib.pyplot as plt +import numpy as np # set up orthographic map projection with # perspective of satellite looking down at 50N, 100W. # use low resolution coastlines. @@ -11,63 +12,41 @@ # draw the edge of the map projection region (the projection limb) map.drawmapboundary() # draw lat/lon grid lines every 30 degrees. -map.drawmeridians(p.arange(0,360,30)) -map.drawparallels(p.arange(-90,90,30)) +map.drawmeridians(np.arange(0,360,30)) +map.drawparallels(np.arange(-90,90,30)) # lat/lon coordinates of five cities. lats=[40.02,32.73,38.55,48.25,17.29] lons=[-105.16,-117.16,-77.00,-114.21,-88.10] cities=['Boulder, CO','San Diego, CA', 'Washington, DC','Whitefish, MT','Belize City, Belize'] # compute the native map projection coordinates for cities. -x,y = map(lons,lats) +xc,yc = map(lons,lats) # plot filled circles at the locations of the cities. -map.plot(x,y,'bo') +map.plot(xc,yc,'bo') # plot the names of those five cities. -for name,xpt,ypt in zip(cities,x,y): - p.text(xpt+50000,ypt+50000,name,fontsize=9) +for name,xpt,ypt in zip(cities,xc,yc): + plt.text(xpt+50000,ypt+50000,name,fontsize=9) # make up some data on a regular lat/lon grid. -nlats = 73; nlons = 145; delta = 2.*p.pi/(nlons-1) -lats = (0.5*p.pi-delta*p.indices((nlats,nlons))[0,:,:]) -lons = (delta*p.indices((nlats,nlons))[1,:,:]) -wave = 0.75*(p.sin(2.*lats)**8*p.cos(4.*lons)) -mean = 0.5*p.cos(2.*lats)*((p.sin(2.*lats))**2 + 2.) +nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1) +lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:]) +lons = (delta*np.indices((nlats,nlons))[1,:,:]) +wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons)) +mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.) # compute native map projection coordinates of lat/lon grid. -x, y = map(lons*180./p.pi, lats*180./p.pi) +x, y = map(lons*180./np.pi, lats*180./np.pi) # contour data over the map. cs = map.contour(x,y,wave+mean,15,linewidths=1.5) # as above, but use blue marble image as map background. -fig = p.figure() -map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l') +fig = plt.figure() map.drawmapboundary() -map.drawmeridians(p.arange(0,360,30)) -map.drawparallels(p.arange(-90,90,30)) -# lat/lon coordinates of five cities. -lats=[40.02,32.73,38.55,48.25,17.29] -lons=[-105.16,-117.16,-77.00,-114.21,-88.10] -cities=['Boulder, CO','San Diego, CA', - 'Washington, DC','Whitefish, MT','Belize City, Belize'] -# compute the native map projection coordinates for cities. -x,y = map(lons,lats) -# plot filled circles at the locations of the cities. -map.plot(x,y,'yo') -# plot the names of those five cities. -for name,xpt,ypt in zip(cities,x,y): - p.text(xpt+50000,ypt+50000,name,fontsize=9,color='w') -# make up some data on a regular lat/lon grid. -nlats = 73; nlons = 145; delta = 2.*p.pi/(nlons-1) -lats = (0.5*p.pi-delta*p.indices((nlats,nlons))[0,:,:]) -lons = (delta*p.indices((nlats,nlons))[1,:,:]) -wave = 0.75*(p.sin(2.*lats)**8*p.cos(4.*lons)) -mean = 0.5*p.cos(2.*lats)*((p.sin(2.*lats))**2 + 2.) -# compute native map projection coordinates of lat/lon grid. -x, y = map(lons*180./p.pi, lats*180./p.pi) +map.drawmeridians(np.arange(0,360,30)) +map.drawparallels(np.arange(-90,90,30)) +# plot the names of five cities. +for name,xpt,ypt in zip(cities,xc,yc): + plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w') # contour data over the map. cs = map.contour(x,y,wave+mean,15,linewidths=1.5) # draw blue marble image in background. map.bluemarble() -p.show() - -#p.savefig('wiki_example.ps') - - +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2008-06-03 16:41:06
|
Revision: 5373 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5373&view=rev Author: jswhit Date: 2008-06-03 09:40:52 -0700 (Tue, 03 Jun 2008) Log Message: ----------- forgot to plot circles in last plot (bluemarble background) Modified Paths: -------------- trunk/toolkits/basemap/examples/wiki_example.py Modified: trunk/toolkits/basemap/examples/wiki_example.py =================================================================== --- trunk/toolkits/basemap/examples/wiki_example.py 2008-06-03 13:36:33 UTC (rev 5372) +++ trunk/toolkits/basemap/examples/wiki_example.py 2008-06-03 16:40:52 UTC (rev 5373) @@ -42,6 +42,8 @@ map.drawmapboundary() map.drawmeridians(np.arange(0,360,30)) map.drawparallels(np.arange(-90,90,30)) +# plot filled circles at the locations of the cities. +map.plot(xc,yc,'wo') # plot the names of five cities. for name,xpt,ypt in zip(cities,xc,yc): plt.text(xpt+50000,ypt+50000,name,fontsize=9,color='w') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |