imshow + pdf export + print = blurry on paper

Hi everyone,

Using ‘imshow’ to plot a few arrays (arranged with gridspec) that I then export directly to a .pdf file using savefig, I noticed that when I print the .pdf file (i.e. on real paper) some of the subplots are blurry.

To clarify:

  • in all my figures, there is always 1 subplot very sharp and crisp, and all the others are slightly blurry,
  • the effect is not visible on the screen at any zoom level,
  • the effect is very slight, and hardly noticeable … until you plot a fine dotted grid - and then, it becomes evident (the grid points pop out a LOT more in the sharp plot),
  • the entire ‘sub-image’ is blurred (axes, on-image text, grids, etc…) but the axis labels and tick labels are fine.

This effect is hard to describe, so I placed an example here: http://www.mso.anu.edu.au/~fvogt/mpl_tmp/
You can compare the original pdf (straight out of Python) and the ‘scanned-printed’ version. The scan is not of the highest quality, but you can definitely see that the grid on the left is fainter - and if you zoom in, the figure’s edges are also less sharp.

I tried (and failed) to find info on the web so far (I’m still searching). In the meantime, has anyone seen this effect before ? Is this a documented bug/feature ?

I suspect that it may be related to how subplots (containing distinct images) are exported to .pdf, but it is a long way beyond my current knowledge of the savefig function. Note that playing with the dpi setting (I went up to 1200) doesn’t help (I can see the improvement on the images themselves but the print blurriness remains). And just in case you wonder, the print bluriness also remains whether I print the .pdf straight out of Python or include it inside a Latex document first.

Any ideas on how to fix/go around this ?

Cheers,
Fréd

P.S.: The effect is not present if I export my figures in png. But for quality purposes, I’d much rather try to avoid going through png if I can …

Interesting development of the issue described below, shared with the list for legacy purposes.

As it turns out, which PDF viewer one uses does matter when it comes to printing (on paper) matplotlib figures containing ‘imshow’ plots and saved as .pdf. The problem I had was the result of printing the matplotlib figure via Mac OSX’s “Preview”. If I print the same figure via Acrobat Reader, then the grid in both panel look identical, the panel edges are sharp and crisp, etc …

This most certainly points out towards a difference deep inside Preview and Acrobat - haven’t tried other PDF viewers.

For reference, I am on Mac OS 10.6, used Preview 5.0.3 and Acrobat reader 10.1.12.

Cheers,

Fréd

···

On 23/10/2014, at 10:07 PM, Frédéric Vogt wrote:

Hi everyone,

Using ‘imshow’ to plot a few arrays (arranged with gridspec) that I then export directly to a .pdf file using savefig, I noticed that when I print the .pdf file (i.e. on real paper) some of the subplots are blurry.

To clarify:

  • in all my figures, there is always 1 subplot very sharp and crisp, and all the others are slightly blurry,
  • the effect is not visible on the screen at any zoom level,
  • the effect is very slight, and hardly noticeable … until you plot a fine dotted grid - and then, it becomes evident (the grid points pop out a LOT more in the sharp plot),
  • the entire ‘sub-image’ is blurred (axes, on-image text, grids, etc…) but the axis labels and tick labels are fine.

This effect is hard to describe, so I placed an example here: http://www.mso.anu.edu.au/~fvogt/mpl_tmp/
You can compare the original pdf (straight out of Python) and the ‘scanned-printed’ version. The scan is not of the highest quality, but you can definitely see that the grid on the left is fainter - and if you zoom in, the figure’s edges are also less sharp.

I tried (and failed) to find info on the web so far (I’m still searching). In the meantime, has anyone seen this effect before ? Is this a documented bug/feature ?

I suspect that it may be related to how subplots (containing distinct images) are exported to .pdf, but it is a long way beyond my current knowledge of the savefig function. Note that playing with the dpi setting (I went up to 1200) doesn’t help (I can see the improvement on the images themselves but the print blurriness remains). And just in case you wonder, the print bluriness also remains whether I print the .pdf straight out of Python or include it inside a Latex document first.

Any ideas on how to fix/go around this ?

Cheers,
Fréd

P.S.: The effect is not present if I export my figures in png. But for quality purposes, I’d much rather try to avoid going through png if I can …



Matplotlib-users mailing list
Matplotlib-users@…2982…e.net
matplotlib-users List Signup and Options

You might try unchecking "Anti-alias text and line art" in the PDF panel in Preview's Preferences dialog to see if that helps.

Best regards,
Scott

···

On Oct 23, 2014, at 8:49 PM, Frédéric Vogt <frederic.vogt@...634...> wrote:

Interesting development of the issue described below, shared with the list for legacy purposes.

As it turns out, which PDF viewer one uses does matter when it comes to printing (on paper) matplotlib figures containing 'imshow' plots and saved as .pdf. The problem I had was the result of printing the matplotlib figure via Mac OSX's "Preview". If I print the same figure via Acrobat Reader, then the grid in both panel look identical, the panel edges are sharp and crisp, etc ...

This most certainly points out towards a difference deep inside Preview and Acrobat - haven't tried other PDF viewers.

For reference, I am on Mac OS 10.6, used Preview 5.0.3 and Acrobat reader 10.1.12.

Cheers,
Fréd

On 23/10/2014, at 10:07 PM, Frédéric Vogt wrote:

Hi everyone,

Using 'imshow' to plot a few arrays (arranged with gridspec) that I then export directly to a .pdf file using savefig, I noticed that when I print the .pdf file (i.e. on real paper) some of the subplots are blurry.

To clarify:
- in all my figures, there is always 1 subplot very sharp and crisp, and all the others are slightly blurry,
- the effect is not visible on the screen at any zoom level,
- the effect is very slight, and hardly noticeable ... until you plot a fine dotted grid - and then, it becomes evident (the grid points pop out a LOT more in the sharp plot),
- the entire 'sub-image' is blurred (axes, on-image text, grids, etc...) but the axis labels and tick labels are fine.

This effect is hard to describe, so I placed an example here: http://www.mso.anu.edu.au/~fvogt/mpl_tmp/
You can compare the original pdf (straight out of Python) and the 'scanned-printed' version. The scan is not of the highest quality, but you can definitely see that the grid on the left is fainter - and if you zoom in, the figure's edges are also less sharp.

I tried (and failed) to find info on the web so far (I'm still searching). In the meantime, has anyone seen this effect before ? Is this a documented bug/feature ?

I suspect that it may be related to how subplots (containing distinct images) are exported to .pdf, but it is a long way beyond my current knowledge of the savefig function. Note that playing with the dpi setting (I went up to 1200) doesn't help (I can see the improvement on the images themselves but the print blurriness remains). And just in case you wonder, the print bluriness also remains whether I print the .pdf straight out of Python or include it inside a Latex document first.

Any ideas on how to fix/go around this ?

Cheers,
Fréd

P.S.: The effect is not present if I export my figures in png. But for quality purposes, I'd much rather try to avoid going through png if I can ...

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options