eps/pdf/svg contourf contours don't overlap properly with high resolution data

Jouni K. Sepp?nen wrote:

Jordan Dawe <jdawe@...128...> writes:

Contourf plots that I output in vector format files have little
triangular glitches at the contour boundaries if the contoured array
is larger than about 200x200. The same files in png format are
perfect, even at very high dpi values.

The current svn trunk doesn't have the really jarring little triangles
(at least in the pdf output), but there are still several very obtuse
white triangles between the regions. Rasterization at a high dpi makes
the output somewhat better at the cost of larger output files:

c=contourf(X, Y, Z, 10)
axis((-3, 3, -3, 3))
for d in c.collections:
At least in the trunk--and maybe in 0.99.0--the problem is caused by path simplification. In the trunk, for the eps file, it goes away completely if I use a matplotlibrc with

path.simplify : False

In the trunk, what seems to be happening is that when a contour boundary is almost straight, but has an inflection point, the curves for the adjacent patch boundaries are simplified slightly differently. This is not surprising; if nothing else, the path will be traveled in a different direction when it is an outer boundary than when it is an inner boundary (for a set of concentric boundaries).

Jordan, try using a local matplotlibrc with the above. Unless you are already customizing via a local matplotlibrc, that line is all you need.

One reason the trunk behavior differs from 0.99.0 is that contour patch boundaries are now being turned into compound boundaries instead of using a branch cut to connect the outside path to the inside path. I suspect simplification is causing the artifacts in both cases, though.


Perfect, that fixed it completely. Thanks.