New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zero size ticks show up as single pixels in rendered pdf #6294
Comments
attn @jkseppan |
I've been trying to reproduce the bug from the example that you gave but haven't been able to. I don't have the exact same setup. I started with the default Ubuntu install of python 2.7, mpl 1.4.2, then moved on to the 1.5.x branch, then python 3.4.3+, mpl 1.4.2 and finally I fetched the official Anaconda Docker container with python3. This made me wonder if the pdf backend depends one some OS specific lib file but as far as I can tell that is not the case. Anyways, I wanted to suggest a workaround until this is solved. You can use
to make the ticks the same color as the background and thus not visible. |
I did some digging and the problem comes from the transformation set for the marker. The ticks use a Line2D with TICKDOWN markers. If the tick size is zero, this just scales the transformation matrix with 0. So a line is still placed at that position, it just has no extent. For some reason this is still rendered as one dot by Adobe Acrobat. Maybe there is some kind of minimum size it expects? So a more basic example that causes that behavior for me is:
So it might well not be a problem of matpotlib, but a bug in my version of Adobe Reader (Adobe Acrobat X version 10.1.16). But I still think no tick should be drawn at all in this case. I noticed I could also set |
@henningpohl: Your assessment makes sense. Regardless of where the bug lies, I think we have to treat Adobe Acrobat as the "reference implementation" of PDF, since it's their standard. They probably just didn't consider scaling things down to 0, which is kind of a weird thing to do. I think it should be possible to modify matplotlib so it just doesn't emit the ticks at all in this case (as you suggest), just haven't gotten around to it. Feel free to file a PR for that -- it sounds like you've already done most of the reconnaissance work... |
In the PDF rendering model, zero-width lines are specified to be drawn at the thinnest width possible on the output device. Because this is different from other backends, I think there is code in the pdf backend to not draw zero-width lines at all. Fun detail from the PDF specification: "If a subpath is degenerate (consists of a single-point closed path or of two or more points at the same coordinates), the S operator paints it only if round line caps have been specified, producing a filled circle centered at the single point. If butt or projecting square line caps have been specified, S produces no output, because the orientation of the caps would be indeterminate." So apparently this bug was triggered by the |
When using the darkgrid seaborn style, no ticks are rendered. However, in the saved pdf single pixels show up at each tick position. This is not the case when saving the figure as png. Here's an example of what I mean:
At first I assumed this is a seaborn bug. But I can replicate the behavior in matplotlib only code as well. A small example would be:
I'm running seaborn 0.7.0 and matplotlib 1.5.1 in python 3.4.4 from Anaconda 2.3.0 on 64 bit Windows. The backend used is QT4Agg.
It's not a huge problem as those pixels are not very prominent. But it seems to me no tick rendering should take place at all in the 0 length case.
The text was updated successfully, but these errors were encountered: