-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Pixelated fonts when plot saved as jpeg #5302
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
Comments
Odd that it only hits the tick labels, but not the other text. Can you please move the images and example code over here? I do not trust SO long-term. |
Here is code to reproduce the pixelated fonts when saving a figure as a jpeg (when using jupyter):
This produces a plot.png shown here: and plot.jpg shown here: Adding the following code will "fix" this issue and produce jpegs that look nearly identical to the png files (with the undesirable side-effect of have non-transparent figures rendered in your jupyter notebooks):
Another example for how PIL handles these transparent regions while trying to encode the raw data into jpeg is given by taking the first example and adding the code:
plot.jpg in this case looks like this: I'm not exactly sure if this problem should be handled by the PIL team of the matplotlib team, but it might be worth looking into adding code to remove transparent regions when trying to save figures to file formats that can't handle transparency. I don't think it would be a difficult issue to fix, and might be able to write up a pull request for a suggested solution at some point in time. This issue also seems to surface when trying to create animations. |
Fix #5302: Proper alpha-blending for jpeg
Fix matplotlib#5302: Proper alpha-blending for jpeg Conflicts: lib/matplotlib/tests/test_image.py
I have noticed that when you save figures as jpeg using the nbagg backend you will get pixelated fonts for labels and tickmarks. It appears this has to do with giving PIL raw data with transparent regions when trying to save jpeg images. This can be avoided with setting: rcParams['nbagg.transparent'] = False.
Is this behavior desired? Perhaps there is a way we can assign default values that will be called for when you have a transparency in a figure and you are trying to save it to a file format that doesn't support transparency?
Please see http://stackoverflow.com/questions/33283274/pixelated-fonts-when-plot-is-saved-as-jpeg for more information.
The text was updated successfully, but these errors were encountered: