On 04/09/2012 04:13 AM, Jouni K. Seppänen wrote:
> Benjamin Root<ben.r...@ou.edu>  writes:
>
>>> It seems that savig a pcolor plot to a pdf format always includes
>>> gridlines, which isn't true for other output formats like png.  The
>>> attached example demonstrates this problem.  I've only tested this on
>>> version 1.1.1rc1.
>>
>> I have reported something like this before, and it seems that it is
>> dependent upon the PDF viewer and i's settings.  Particularly, the
>> antialiasing settings.  I have seen this with gs-based viewers. Have you
>> tried others?
>
> I see gridlines in the resulting image in gs, xpdf Preview.app but not
> in Adobe Reader. When I zoom in Preview, the lines jump around a bit,
> and are always the same width on the screen regardless of zoom level.
>
> What gets drawn in this example is a lot of polygons, so that adjacent
> polygons share an edge with the exact same coordinates. The code fills
> the inside of each polygon, and apparently some rendering algorithms
> leave a minimal-width line between polygons.
>
> Making the polygons overlap by one pdf unit (1/72 of an inch) seems to
> make the lines go away at least in Preview. Making them overlap by 0.1
> units does not help.

Does it make them go away with alpha = 0.5, say?

>
> I don't think this can be fixed purely in the pdf backend; it just gets
> a path collection and draws each polygon. I suppose pcolor would need to
> pad the polygons a little, but could it cause problems with other
> backends or use cases? (E.g. if you use alpha blending, neighboring
> rectangles might get gridlines of a darker color where they overlap.)

I'm very skeptical about attempted workarounds such as padding; I would 
be amazed if any of them work over the full range of cases--backends, 
alpha, antialiasing, viewers--while maintaining accuracy of plot element 
placement.

Has cairo solved this problem?  Anyone else?

>
> I wonder if drawing zero-width lines between neighboring rectangles,
> e.g. taking the color always from the left or the upper rectangle, would
> work. In matplotlib a line of zero width means no line at all, but in
> the pdf file format it means a line of the smallest possible width,
> which might work well for filling in a missing line of that same
> width. This would need some kind of special-casing in the graphics
> context (because linewidth=0 means to not draw a line) so it's not
> completely trivial to try it out.

Problems occur not just with rectangles but with all patch boundaries, 
such as in contourf.  The problem may be most severe with rectangles, 
though.

We have gone around in circles with this problem before.

>
> A different approach would be to output a raster image from pcolor and
> render it with large pixels. I don't know how well that would work with
> Agg, though.
>
I don't understand; wouldn't this wreck accuracy and defeat the purpose 
of using pdf (scalability)?

Eric


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to