Revision: 5168
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5168&view=rev
Author: jswhit
Date: 2008-05-17 05:22:09 -0700 (Sat, 17 May 2008)
Log Message:
-----------
convert to pyplot/numpy namespace
Modified Paths:
--------------
trunk/toolkits/basemap/examples/contour_demo.py
Modified: trunk/toolkits/basemap/examples/contour_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/contour_demo.py 2008-05-17 12:04:34 UTC
(rev 5167)
+++ trunk/toolkits/basemap/examples/contour_demo.py 2008-05-17 12:22:09 UTC
(rev 5168)
@@ -1,124 +1,125 @@
from mpl_toolkits.basemap import Basemap, shiftgrid
-from pylab import load, show, colorbar, axes, gca,\
- figure, title, meshgrid, cm, arange
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
# examples of filled contour plots on map projections.
# read in data on lat/lon grid.
-hgt = load('500hgtdata.gz')
-lons = load('500hgtlons.gz')
-lats = load('500hgtlats.gz')
+hgt = mlab.load('500hgtdata.gz')
+lons = mlab.load('500hgtlons.gz')
+lats = mlab.load('500hgtlats.gz')
# shift data so lons go from -180 to 180 instead of 0 to 360.
hgt,lons = shiftgrid(180.,hgt,lons,start=False)
-lons, lats = meshgrid(lons, lats)
+lons, lats = np.meshgrid(lons, lats)
# create new figure
-fig=figure()
+fig=plt.figure()
# setup of sinusoidal basemap
m = Basemap(resolution='c',projection='sinu',lon_0=0)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# make a filled contour plot.
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)
+CS = m.contourf(x,y,hgt,15,cmap=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]) # setup colorbar axes
-colorbar(drawedges=True, cax=cax) # draw colorbar
-axes(ax) # make the original axes current again
+cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
+plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawmapboundary()
m.fillcontinents()
# draw parallels and meridians.
-parallels = arange(-60.,90,30.)
+parallels = np.arange(-60.,90,30.)
m.drawparallels(parallels,labels=[1,0,0,0])
-meridians = arange(-360.,360.,30.)
+meridians = np.arange(-360.,360.,30.)
m.drawmeridians(meridians)
-title('Sinusoidal Filled Contour Demo')
+plt.title('Sinusoidal Filled Contour Demo')
print 'plotting with sinusoidal basemap ...'
# create new figure
-fig=figure()
+fig=plt.figure()
# setup of mollweide basemap
m = Basemap(resolution='c',projection='moll',lon_0=0)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# make a filled contour plot.
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)
+CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
pos = ax.get_position()
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
+cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
+plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawmapboundary()
m.fillcontinents()
# draw parallels and meridians.
-parallels = arange(-60.,90,30.)
+parallels = np.arange(-60.,90,30.)
m.drawparallels(parallels,labels=[1,0,0,0])
-meridians = arange(-360.,360.,30.)
+meridians = np.arange(-360.,360.,30.)
m.drawmeridians(meridians)
-title('Mollweide Filled Contour Demo')
+plt.title('Mollweide Filled Contour Demo')
print 'plotting with mollweide basemap ...'
# create new figure
-fig=figure()
+fig=plt.figure()
# set up Robinson map projection.
m = Basemap(resolution='c',projection='robin',lon_0=0)
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# make a filled contour plot.
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)
+CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
pos = ax.get_position()
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
+cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
+plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawmapboundary()
m.fillcontinents()
# draw parallels and meridians.
-parallels = arange(-60.,90,30.)
+parallels = np.arange(-60.,90,30.)
m.drawparallels(parallels,labels=[1,0,0,0])
-meridians = arange(-360.,360.,60.)
+meridians = np.arange(-360.,360.,60.)
m.drawmeridians(meridians,labels=[0,0,0,1])
-title('Robinson Filled Contour Demo')
+plt.title('Robinson Filled Contour Demo')
print 'plotting with robinson basemap ...'
# create new figure
-fig=figure()
+fig=plt.figure()
# set up map projection (azimuthal equidistant).
m = Basemap(projection='npaeqd',lon_0=-90,boundinglat=15.,resolution='c')
ax = fig.add_axes([0.1,0.1,0.7,0.7])
# make a filled contour plot.
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)
+CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
pos = ax.get_position()
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
+cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
+plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawmapboundary()
m.fillcontinents()
# draw parallels and meridians.
-parallels = arange(0.,80,20.)
+parallels = np.arange(0.,80,20.)
m.drawparallels(parallels,labels=[0,0,1,1])
-meridians = arange(10.,360.,20.)
+meridians = np.arange(10.,360.,20.)
m.drawmeridians(meridians,labels=[1,1,1,1])
-title('Azimuthal Equidistant Filled Contour Demo',y=1.075)
+plt.title('Azimuthal Equidistant Filled Contour Demo',y=1.075)
print 'plotting with azimuthal equidistant basemap ...'
# create new figure
-fig=figure()
+fig=plt.figure()
# setup of orthographic basemap
m = Basemap(resolution='c',projection='ortho',\
lat_0=50.,lon_0=-120.)
@@ -126,22 +127,22 @@
# make a filled contour plot.
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)
+CS = m.contourf(x,y,hgt,15,cmap=plt.cm.jet)
pos = ax.get_position()
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
+cax = plt.axes([l+w+0.075, b, 0.05, h]) # setup colorbar axes
+plt.colorbar(drawedges=True, cax=cax) # draw colorbar
+plt.axes(ax) # make the original axes current again
# draw coastlines and political boundaries.
m.drawcoastlines()
m.fillcontinents()
m.drawmapboundary()
# draw parallels and meridians.
-parallels = arange(-80.,90,20.)
+parallels = np.arange(-80.,90,20.)
m.drawparallels(parallels)
-meridians = arange(0.,360.,20.)
+meridians = np.arange(0.,360.,20.)
m.drawmeridians(meridians)
-title('Orthographic Filled Contour Demo')
+plt.title('Orthographic Filled Contour Demo')
print 'plotting with orthographic basemap ..'
-show()
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins