Thanks, that works fantastically ! -- Forest.
On Fri, Sep 17, 2010 at 9:23 PM, Benjamin Root <ben.r...@ou.edu> wrote: > On Fri, Sep 17, 2010 at 8:05 PM, Forest Yang <yzine0...@gmail.com> wrote: >> >> Hi >> >> I have a function z(x, y) on a regular grid. But some of the value >> z are not defined on (x,y). I want to plot the contour or contourf of >> z on (x,y) but exclude specific (x,y) points. >> How can I do it ? Right now I just draw small colored square >> (rectangular) around defined (x,y) the color is not smooth since no >> interpolation like contour or contourf. >> >> Thanks. >> >> Forest. >> > > Forest, > > There are a few ways to do this. If you have a recent enough version of > matplotlib, you can use masked arrays, and the contourf will just ignore > those data points. One could also use NaNs and make sure that the clim (the > limits on z that you wish to display a color for) is defined. > > To make a masked array is easy. Imagine you wish to exclude any value less > than zero (assume z is defined): > > import numpy.ma as ma > z_masked = ma.masked_array(z, mask=(z < 0.)) > > And then just use the masked array in your contourf as you would the > regular numpy array. > > I hope that helps! > Ben Root > > ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users