You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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:
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.
Activity
tacaswell commentedon Oct 24, 2015
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.
cbreeden commentedon Oct 25, 2015
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 matplotlib#5302: Proper alpha-blending for jpeg
Merge pull request #5324 from mdboom/transparent-jpg
Merge pull request matplotlib#5324 from mdboom/transparent-jpg