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
alpha is not set correctly when using eps format #1740
Comments
Unfortunately, the postscript format does not support alpha, so there's little we can do there. Some libraries, such as Cairo, fake it by rendering some things as images, but matplotlib doesn't do that. |
According to wikipedia postscript does support transparency. Also, I created this using inkscape and it does render alpha channels: http://ompldr.org/vaGViZg/drawing.eps (However, I think inkscape uses cairo and poppler, which is why it is able to use transparency). Take away from this is - matplotlib (and ps in general) does not support writing alpha channels. I guess, you can close this ticket, unless you want to keep it open for some far-off future implementation. |
The important note in the Wikipedia article is (emphasis mine): The PostScript language has limited support for full (not partial) transparency. Inkscape does indeed emulate alpha blending by converting parts of the output to an image. The downside of this is that the Postscript file is no longer infinitely scalable, and will start to look blocky when zoomed in. It's a tradeoff, and I understand why it was made. If that behavior is ok for you, you can always use matplotlib's Cairo backend to generate the postscript file. I'm going to close this bug, but feel free to reopen if any implementation ideas or solutions occur in the future. |
xref matplotlib#1740 I suspect that the performance implications of this change are acceptable, since it's doing only a tiny fraction of the work the rest of the backend is doing, but I haven't tested it on a large image. This change will save people like me from considerable embarrassment; I almost submitted a paper with a figure containing an awful lot of black ink where faint shadows should have been, but luckily I have sharp-eyed coauthors.
In 764227f, the following warning was added
How can I explicitly remove transparency from my figure and avoid this warning? |
@darkdragon-001 To answer that we would probably have to see your code. This question is probably best handled on the mailing list. My complete knee-jerk guess is that you have a legend in your figure which now defaults to a semi-transparent background. |
Consider the following piece of code:
The image
a.eps
gets a solid fill that would be obtained if we gavealpha=1
(butalpha=0.0
gives an empty fill, as it should). And the imagea.pdf
gets the correct alpha 0.1 fill.The text was updated successfully, but these errors were encountered: