[EMAIL PROTECTED] wrote:
> Hi,
> matplotlib can make a contour plot on a masked array z using
> contourf(x,y,z).but it seems that it draws in a raster mode.there is
> sawtooth at the edge of the picture when it is zoomed.can contour be
> drawed in a vector mode? i means that
> 1) give an array z which has not been masked.
> 2) contourf
> 3) using a ploygon array as a mask instead of using a masked grid array.
> the part out of the polygon will be clipped.it seems that cairo and agg can
> both work in this way.

contourf is not drawing in raster mode--it is generating filled 
polygons.  What you are seeing is the fact that when it follows the edge 
of a masked region, it does so in a stairstep fashion.  This is inherent 
in the algorithm being used.  I have thought a little bit about ways of 
making it at least take a diagonal path when reasonable so as to reduce 
the jaggy effect.  I am not at all sure it would be worth the trouble, 
though--I expect it would be a lot of work for only a little gain.

To get around this you may want to use some interpolation/extrapolation 
to extend your data one grid point into the masked region, then contour 
with the reduced masked region, then plot your own filled polygon on top 
of the contour plot to define the masked region more precisely to your 
taste.

Yes, I agree that this is a pain, and that the present contour/contourf 
routine is not ideal (although it is very clever and I suspect very 
fast).  If you can find a better filled contour routine with a BSD-style 
license, or even a clear and complete description of a superior 
algorithm that could be implemented without running into copyright or 
patent problems, please point it out to us.

There is one interesting difference between the algorithm we use (taken 
from the gist package) and the one used by Matlab: ours generates 
polygons that enclose only a given level--polygons do not 
overlap--whereas Matlab's generates polygons that stack.  As a result, 
ours is suitable for use with alpha blending, whereas Matlab's is not 
(last time I looked, anyway).

Eric

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to