I have looked into various aspects of the problem you reported. It
seems to be essentially a problem with antialiasing; all artifacts go
away in the AGG backend with antialiasing turned off, regardless of the
linewidth, right down to zero. With antialiasing on, however, it seems
that a linewidth of about 0.5 with AGG (on my machine, with everything
default) is needed to prevent the antialiasing from leaving light lines
at polygon boundaries, regardless of whether they are the straight
boundaries caused by chunking or the curved boundaries of the contours
themselves. With Postscript, as rendered by ghostscript via gv, I see
artifacts only with a much smaller linewidth, and only at some
magnifications. Your ps viewers may be doing more antialiasing, and
therefore showing artifacts over a larger range of linewidths. There is
probably more going on, and more to be understood, but this got me far
enough to manage the problem for now.
It looks like there is no problem with simply turning off the chunking.
I have made a bunch of changes in CVS, including turning off the
chunking by default, and allowing one to specify chunking, antialiasing,
and linewidth explicitly for contourf. So, I think you will find that
if you use the CVS version, the problems you reported will go away. If
you haven't done it before, you will find that downloading and
installing from CVS is very quick and easy; instructions are given on
the sourceforge download site. (As John notes, there may be a lag
between developer CVS and the mirrors; make sure that what you download
includes my changes, committed a few minutes ago.) Alternatively, if
you simply want to turn off chunking in 0.84, you can do it by editing
cntr.c, approximately line 1384, change
long nchunk = 30; /* hardwired for now */
long nchunk = 0; /* hardwired for now */
If you use the CVS version (or the next mpl release, whenever that comes
out), note that the APIs for contour, contourf, and clabel have changed
as described in API_CHANGES and as illustrated in
examples/contour_demo.py and contourf_demo.py.
Jordan Dawe wrote:
> Eric Firing wrote:
>> Thanks, now I see the problem and where it is coming from. In
>> contour.py, near the bottom, in the contourf method, change the
>> linewidth from 1 to 0.01, so the line reads:
>> col = PolyCollection(nlist, linewidths=(0.01,))
>> I think this will be OK; based on the comment below the line, I think
>> I found that using a linewidth of zero was problematic, so I probably
>> simply used 1 thinking it was small enough not to matter.
>> I will need to make a corresponding change in the CVS version so that
>> it will get into the next release. I'll do that this evening.
> Sorry about this, but that patch doesn't seem to work. When I open the
> eps files generated with this change implimented, I get the artifact
> problem mentioned in the comment; fine lines at the boundaries of the
> contouring engine's subdomains. In fact, I get the artifacts at
> linewidths as large as 0.5.