Ok... how about this?

import numpy as np

from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

# generate some random data - i.e. what would be an image of the world, say

different

# land covers

data = np.random.randint(10,27,100*67).reshape(100, 67)

# I want to draw a boundary round each land cover type, so

# classify a new array

data2 = np.where(data == 10, 1, data)

data2 = np.where(data == 11, 1, data)

data2 = np.where(data == 13, 2, data)

data2 = np.where(data == 14, 2, data)

data2 = np.where(data == 15, 2, data)

data2 = np.where(data == 16, 2, data)

data2 = np.where(data == 18, 3, data)

data2 = np.where(data == 19, 3, data)

data2 = np.where(data == 20, 3, data)

data2 = np.where(data == 26, 4, data)

data2 = np.where(data == 27, 4, data)

plt.contour(data2)

plt.show()

sys.exit()

this pops up a contour plot...

Now what if as I do I want to overlay this on a basemap plot...

import numpy as np

from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

# generate some random data - i.e. what would be an image of the world, say

different

# land covers

data = np.random.randint(10,27,100*67).reshape(100, 67)

# I want to draw a boundary round each land cover type, so

# classify a new array

data2 = np.where(data == 10, 1, data)

data2 = np.where(data == 11, 1, data)

data2 = np.where(data == 13, 2, data)

data2 = np.where(data == 14, 2, data)

data2 = np.where(data == 15, 2, data)

data2 = np.where(data == 16, 2, data)

data2 = np.where(data == 18, 3, data)

data2 = np.where(data == 19, 3, data)

data2 = np.where(data == 20, 3, data)

data2 = np.where(data == 26, 4, data)

data2 = np.where(data == 27, 4, data)

fig = plt.figure(figsize=(8, 6))

m = Basemap(llcrnrlon=1.5, llcrnrlat=10.5, urcrnrlon=3.5, urcrnrlat=13.5,

resolution='c', projection='cyl')

ax = fig.add_axes([0.1, 0.1, 0.6, 0.7])

m.ax = ax

delta = 0.03

x = np.arange(1.5, 3.5, delta)

y = np.arange(10.5, 13.5, delta)

X, Y = np.meshgrid(x, y)

im = m.imshow(data, interpolation='nearest', cmap=plt.cm.jet)

m.contour(data2, X, Y, color='black')

plt.show()

This only plots the basemap without the contours?

Many thanks,

Martin

## ···

–

View this message in context: http://old.nabble.com/Basemap-%2B-contour-layer--tp29235080p29237074.html

Sent from the matplotlib - users mailing list archive at Nabble.com.