Revision: 8599
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8599&view=rev
Author:   jswhit
Date:     2010-07-30 16:12:48 +0000 (Fri, 30 Jul 2010)

Log Message:
-----------
update broken basemap toolkit screenshot

Modified Paths:
--------------
    trunk/matplotlib/doc/pyplots/plotmap.py
    trunk/matplotlib/doc/users/screenshots.rst

Modified: trunk/matplotlib/doc/pyplots/plotmap.py
===================================================================
--- trunk/matplotlib/doc/pyplots/plotmap.py     2010-07-30 12:28:08 UTC (rev 
8598)
+++ trunk/matplotlib/doc/pyplots/plotmap.py     2010-07-30 16:12:48 UTC (rev 
8599)
@@ -1,66 +1,41 @@
-# make plot of etopo bathymetry/topography data on
-# lambert conformal conic map projection, drawing coastlines, state and
-# country boundaries, and parallels/meridians.
-
-# the data is interpolated to the native projection grid.
-import os
-from mpl_toolkits.basemap import Basemap, shiftgrid
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
 import numpy as np
-
-from pylab import title, colorbar, show, axes, cm, arange, figure, \
-                  text
-
-# read in topo data (on a regular lat/lon grid)
-# longitudes go from 20 to 380.
-# you can get this data from matplolib svn matplotlib/htdocs/screenshots/data/
-datadir = '/home/jdhunter/python/svn/matplotlib/trunk/htdocs/screenshots/data/'
-if not os.path.exists(datadir):
-    raise SystemExit('You need to download the data with svn co 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/htdocs/screenshots/data/";
 and set the datadir variable in %s'%__file__)
-
-topoin = np.loadtxt(os.path.join(datadir, 'etopo20data.gz'))
-lons = np.loadtxt(os.path.join(datadir, 'etopo20lons.gz'))
-lats = np.loadtxt(os.path.join(datadir, 'etopo20lats.gz'))
-# shift data so lons go from -180 to 180 instead of 20 to 380.
-topoin,lons = shiftgrid(180.,topoin,lons,start=False)
-
-# setup of basemap ('lcc' = lambert conformal conic).
-# use major and minor sphere radii from WGS84 ellipsoid.
-m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
-            rsphere=(6378137.00,6356752.3142),\
-            resolution='l',area_thresh=1000.,projection='lcc',\
-            lat_1=50.,lon_0=-107.)
-# transform to nx x ny regularly spaced native projection grid
-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=(6,6))
-# 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)
-# 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])
-colorbar(cax=cax) # draw colorbar
-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')
-# 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.)
-m.drawparallels(parallels,labels=[1,1,0,1])
-meridians = arange(10.,360.,30.)
-m.drawmeridians(meridians,labels=[1,1,0,1])
-# set title.
-title('ETOPO Topography - Lambert Conformal Conic')
-show()
+# create figure
+fig = plt.figure(figsize=(8,8))
+# set up orthographic map projection with
+# perspective of satellite looking down at 50N, 100W.
+# use low resolution coastlines.
+map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l')
+# 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.
+xc,yc = map(lons,lats)
+# make up some data on a regular lat/lon grid.
+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.
+# (convert lons and lats to degrees first)
+x, y = map(lons*180./np.pi, lats*180./np.pi)
+# draw map boundary
+map.drawmapboundary(color="0.9")
+# draw graticule (latitude and longitude grid lines)
+map.drawmeridians(np.arange(0,360,30),color="0.9")
+map.drawparallels(np.arange(-90,90,30),color="0.9")
+# 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+100000,ypt+100000,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.
+# (downsample the image by 50% for speed)
+map.bluemarble(scale=0.5)
+plt.show()

Modified: trunk/matplotlib/doc/users/screenshots.rst
===================================================================
--- trunk/matplotlib/doc/users/screenshots.rst  2010-07-30 12:28:08 UTC (rev 
8598)
+++ trunk/matplotlib/doc/users/screenshots.rst  2010-07-30 16:12:48 UTC (rev 
8599)
@@ -188,13 +188,9 @@
 Basemap demo
 ============
 
-Jeff Whitaker provided this example showing how to efficiently plot a
-collection of lines over a colormap image using the
-:ref:`toolkit_basemap` .  Many map projections are handled via the
-proj4 library: cylindrical equidistant, mercator, lambert conformal
-conic, lambert azimuthal equal area, albers equal area conic and
-stereographic.  See the `tutorial
-<http://www.scipy.org/wikis/topical_software/Maps>`_ entry on the wiki.
+Jeff Whitaker's :ref:`toolkit_basemap` add-on toolkit makes it possible to 
plot data on many
+different map projections.  This example shows how to plot contours, markers 
and text
+on an orthographic projection, with NASA's "blue marble" satellite image as a 
background.
 
 .. plot:: pyplots/plotmap.py
 


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

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to