Evidently the reason we see different things is because the result with linewidth < 1 is renderer-dependent; ghostview (which I am using) and Illustrator handle the same file differently.
To be sure we are agreeing on the phenomenon: Initially, with linewidth=1 in the contourf polygon generation, there was no problem with the subregion boundaries, but the polygons were a bit too large, so that thin line contours did not land exactly on the boundaries. Setting linewidth=0.01 fixes that problem, but introduces renderer-dependent artifacts at the subregion boundaries.
The real solution, or part of it, may be in the backend (ps at least, maybe others): I think that we want to be able to specify a polygon with a zero-width boundary, such that it is filled but not stroked. Alternatively, it may be that the problem is one of rounding in the conversion of floating point vertices to integers in the renderer, in which case removing the boundary line entirely won't help at all.
The division of the domain by cntr.c into subregions is controllable by a parameter; I can expose that parameter to the python level (this weekend, not this minute). Then setting it to a sufficiently large value will take care of the grid problem; and maybe it will have no bad side-effects. According to the comment in the contouring code, the reason for subdividing is that renderers bog down when filling polygons with too many vertices. It may be that this is no longer a problem; that comment may date from an earlier era.
Jordan Dawe wrote:
Yeah, I see artifacts in the eps file you sent me. I'm looking at it in Illustrator CS, and the artifacts show up in Adobe Acrobat 6.0 as well. They also show up when I take the eps and do a 'convert example.eps example.png' on it. The resulting png is attached.
The artifacts tend to change when I zoom in, so I'm guessing some of it is related to the renderer in Illustrator, but I'm still worried they will show up when they go to press. When the linewidth =1.0, the artifacts don't show up at all, so I know it's possible to get rid of them.
I'm willing to hunt through and try to fix this problem, but where would it show up? In the PS render code? In the polygon handers? I know a fair bit of python, but I don't know my way around matplotlib very well...
Also, do you see any problems with me trying to make the cntr.c code output one polygon per simply-connected region? Cause the current "divide the fig up into 48 smaller areas" thing is annoying as hell when you're working with eps. Matlab's renderer does this, why can't this one?