In the mpl basemap '' script, I want to add some contours to the mercator projection map (test #3).  Just below line 83 (ie, below the 'im  = imshow..' command I added the line:

m.contour(topodat,[-1000, -2000])

This returns:

     82 # plot image over map.
     83 im = m.imshow(topodat,cm.jet)
---> 84 m.contour(topodat,[-1000, -2000])
     85 m.drawcoastlines ()
     86 m.drawcountries()

TypeError: contour() takes at least 4 arguments (3 given)
WARNING: Failure executing file: <>

I understand the error to mean that I haven't supplied x and y values; however at this point, if I close all the open figures and enter the line 'contour(topodat,[-1000, -2000])' at the ipython command, it gives me the plot I want.

I've then tried to use meshgrid to make x and y values (see code below); this is error free but the contours don't appear.  Again, using contour in the command line I get the plot I want.  Is it not possible to plot on top of imshow?

Any help appreciated.

Thanks, Evan

from matplotlib.toolkits.basemap import Basemap, shiftgrid
from scipy import interpolate as Pinterp
from pylab import *
import matplotlib.colors as colors

def doSpline(yVec, newLatRange):
    latRange    = range(len(yVec))
    newLatRange = linspace(latRange[0], latRange[-1], newLatRange)
    tck         = Pinterp.splrep(latRange, yVec)
    yVec        = Pinterp.splev(newLatRange, tck)
    return yVec

topodatin = load('etopo20data.gz')
lonsin = load('etopo20lons.gz')
latsin = load('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topodatin,lonsin,start=False)
lats = latsin
# transform to nx x ny regularly spaced native projection grid
nx = len(lons)
ny = int(80.*len(lats)/90.)
lats_ny = doSpline(lats, ny)

lons_mesh, lats_mesh = meshgrid(lons, lats_ny)

# setup mercator map projection (-80 to +80).
m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\

topodat = m.transform_scalar(topoin,lons,lats,nx,ny)

# setup figure with same aspect ratio as map.
# plot image over map.
im = m.imshow(topodat,cm.jet)
m.contour(lons_mesh, lats_mesh, topodat,[-1000, -2000, -3000])