Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: <shuwj5460@16...>  20061224 05:47:18

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. shu  <> 
From: Eric Firing <efiring@ha...>  20061224 19:46:17

shuwj5460@... 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 modeit 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, thoughI 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 BSDstyle 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 levelpolygons do not overlapwhereas 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 
From: <shuwj5460@16...>  20061225 06:46:06

> contourf is not drawing in raster modeit is generating filled=20 > polygons. What you are seeing is the fact that when it follows the edge= =20 > of a masked region, it does so in a stairstep fashion. This is inherent= =20 > in the algorithm being used. it seems that the filled polygon is composed of a set of points in some a contour and some points in the 'drawn' edge which offsets with the real edge of a masked region.=20 > I have thought a little bit about ways of=20 > making it at least take a diagonal path when reasonable so as to reduce= =20 > the jaggy effect. I am not at all sure it would be worth the trouble,=20 > thoughI expect it would be a lot of work for only a little gain. I do think that matplotlib can do a very good job now. the same time i think it's valuable to take some time to work out this little flaw. maybe there're some tricky methods. 1) make a contourf plot on the whole rectangle mesh with no mask. 2) make a mask picture of the same size with the contourf plot. black in mask ploygon and white outside. 3) do AND operation on contourf plot and the mask picture and outside the mask polygon will be clipped. x,y is axes array. z is mesh grid data array. zz is mesh grid data array with mask. p is polygon for the edge. cs=3Dcontourf(x,y,z) > contourf plot,identifies A.=20 cs2=3Dcontour(x,y,zz) =20 clabel(cs2,....) > label at the right position inside the mask polygon. draw_polygon(p,fillcolor=3Dblack) > make a mask picture of the same size with A,identifies B. A and B drawing. > it seems that cairo and agg can do this. i don't know how to do in matplotlib.but i'm sure some functions work for it. there's no need to change the mask array when we zoom the picture now because the mask picture is redrawn dynamicaly and 'vectorly' =2E >=20 > To get around this you may want to use some interpolation/extrapolation= =20 > to extend your data one grid point into the masked region, then contour= =20 > with the reduced masked region, then plot your own filled polygon on top= =20 > of the contour plot to define the masked region more precisely to your=20 > taste. yes,filled contour map with smooth edge can be drawn with a more high resolution mask array given.it's not a hard job.However,there's some disadvantages in this way.firstly,mask array will have much larger size than before and x,y arrays will be enlarged.these steps should be repeated every time we wanna zoom the picture. > Yes, I agree that this is a pain, and that the present contour/contourf= =20 > routine is not ideal (although it is very clever and I suspect very=20 > fast). If you can find a better filled contour routine with a BSDstyle= =20 > license, or even a clear and complete description of a superior=20 > algorithm that could be implemented without running into copyright or=20 > patent problems, please point it out to us. >=20 > There is one interesting difference between the algorithm we use (taken= =20 > from the gist package) and the one used by Matlab: ours generates=20 > polygons that enclose only a given levelpolygons do not=20 > overlapwhereas Matlab's generates polygons that stack. As a result,=20 > ours is suitable for use with alpha blending, whereas Matlab's is not=20 > (last time I looked, anyway). > Eric would you like to add some more interpolation algorithm such as kriging ect.to matplotlib? there are many interpolation source codes in public. shu =20 <> 
Sign up for the SourceForge newsletter:
No, thanks