how can i make a contour plot with mask

Shu: I'd make a mask by finding the points on the grid that are outside
your polygon. Then use that mask to create a masked array from your
data (masking the points you don't want to plot). matplotlib's contourf
knows how to deal with masked arrays (at least when the masked region
isn't too complicated). The basemap toolkit can plot data on map
projections with coastlines and political boundaries (as in the PyNGL
example you forwarded).

-Jeff

Thanks Jeff.Following your advice I have successed to get a masked
contour plot.Matplotlib can do it good.

in my case,
x is array for axis X and y for axis Y
z is data for contour
mask is a mask array with the same dimensions as z.
ma.array(z,mask=mask)
contour(x,y,z)

In my case,I used kriging interpolation to interpolate an array of
irregulation station data into a rectangular grid first and then plot
contour with matplotlib. I wanna know if matplotlib have such
interpolation functions or geostatistics functions.

Thanks again.

shu

shuwj5460@...1221... wrote:

Shu: I'd make a mask by finding the points on the grid that are outside your polygon. Then use that mask to create a masked array from your data (masking the points you don't want to plot). matplotlib's contourf knows how to deal with masked arrays (at least when the masked region isn't too complicated). The basemap toolkit can plot data on map projections with coastlines and political boundaries (as in the PyNGL example you forwarded).

-Jeff
    
Thanks Jeff.Following your advice I have successed to get a masked
contour plot.Matplotlib can do it good.

in my case,
x is array for axis X and y for axis Y
z is data for contour
mask is a mask array with the same dimensions as z.
ma.array(z,mask=mask)
contour(x,y,z)

In my case,I used kriging interpolation to interpolate an array of
irregulation station data into a rectangular grid first and then plot
contour with matplotlib. I wanna know if matplotlib have such
interpolation functions or geostatistics functions.

Thanks again.

shu

Shu: It's not included in matplotlib, but see

http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328