17
$\begingroup$

This is fixed for in version 10.3 by disabling interpolation in the PDF (see Romwell's answer). However, Preview.app on OS X simply ignores this flag. Thus, in practice, the problem remains for all but small matrices. Systems other than Mathematica are also affected by this Preview.app problem.


[The following problem occurs on OS X; I don't know if it also occurs with other OS's.]

If I produce a Graphics object with ArrayPlot, right-click on it, choose "Save Graphic As...", and save it as a PDF file, the resulting PDF graphic is absurdly fuzzy/blurry (which is particularly perverse, considering that it is among the simplest kind of graphics (all solid-color squares with vertical and horizontal edges).

For example, in the PNG screenshot below, one such figure is shown in the Mathematica GUI (on the left), and the PDF file exported as described above (and displayed at "Actual Size" magnification with the Preview app) is shown on the right:

original vs PDF

(Actually, the screenshot of the original on the left looks fuzzier to me than what I actually see on the screen, but that degree of fuzziness is nothing compared to what the PDF looks like.)

As I understand it PDF is the native graphics format for OS X. It should be possible (not to say trivial) to save this very simple graphic as a PDF in a way that preserves all the edges and corners to infinite resolution.

Does anyone know how?

PS: FWIW, I did try displaying the Graphics object above with Style[#, Antialiasing->False]&, but this change had no effect, either on the resulting PDF nor on the object's appearance in the Mathematica GUI.

$\endgroup$
6
  • 2
    $\begingroup$ Does the same thing happen if you use Export["file.pdf", ArrayPlot[(* stuff *)]]? $\endgroup$ Sep 29, 2012 at 16:13
  • $\begingroup$ @J.M. Yes, same problem. The only difference this time is that, when this second PDF is displayed at "Actual Size" magnification, the plot has the same size as it does in the Mathematica GUI. $\endgroup$
    – kjo
    Sep 29, 2012 at 16:25
  • 4
    $\begingroup$ This is a problem with Preview.app, not Mathematica. Try opening it in Adobe Reader or ghostview and it'll look correct $\endgroup$
    – rm -rf
    Sep 29, 2012 at 16:51
  • $\begingroup$ note that pl = ArrayPlot[Table[i - j, {i, 5}, {j, 5}]]; Export["pl.pdf", pl]; produces a non fuzzy array (macos 10.7 preview). $\endgroup$
    – chris
    Sep 29, 2012 at 17:45
  • $\begingroup$ @rm-rf: Thanks! If you post your comment, I'll by happy to accept it. $\endgroup$
    – kjo
    Sep 29, 2012 at 19:41

3 Answers 3

13
$\begingroup$

This is a problem with Preview, the PDF reader included in OS X. The problem does not show when using other PDF readers (not based on PDFKit) such as Adobe Reader.

To prevent blurring you just need to untick the "Smooth text and line art" checkbox under "Viewing documents" in Preview's preferences:

in the preview pdf preferences

However, this will lower the quality of text and line art as well.

$\endgroup$
12
$\begingroup$

Actually, the problem is with Mathematica's export, at least with Version 10.

I have been saving a file wit MatrixPlot (using Save As...-> PDF), and have encountered the same problem.

Turns out, MatrixPlot (and similar) data is being exported as a bitmap, which gets blurred in Adobe Reader 9 (which I have), even if "Smooth line art" and "Smooth images" is unchecked in preferences. The PDF showed fine in Okular, but that is probably just the lack of smoothing in that viewer.

I have found the solution on Inkscape forums. Open the PDF file in a text editor, and locate the following line:

/Interpolate true

Change it to the following:

/Interpolate false

Et voilà! The problem is solved, and the PDF shows fine in Adobe Reader, without blurring.

I have not found a setting in Mathematica to affect the value of this option on export to PDF.

$\endgroup$
4
  • 1
    $\begingroup$ Under Windows I do not see the Interpolate word in the PDF file even after uncompressing the streams inside it by the command qpdf --stream-data=uncompress in.pdf out.pdf. The PDF file is generated in MMa 10.0.1 by the command Export["in.pdf", MatrixPlot[{{1, 2, 1}, {3, 0, 1}, {0, 0, -1}}]]. $\endgroup$ Nov 19, 2014 at 9:46
  • $\begingroup$ I'm using Mathematica 10.0.0 for Linux 64-bit, which version do you have? $\endgroup$ Nov 19, 2014 at 20:22
  • $\begingroup$ I have MMa 10.0.1 under Win7 x64. $\endgroup$ Nov 19, 2014 at 20:25
  • $\begingroup$ I wonder if they simply fixed it in an update. $\endgroup$ Nov 19, 2014 at 20:27
1
$\begingroup$

In version 9 of Mathematica, if you export the graphics by right clicking and choosing Save As..., the problem does not occur. Unfortunately this will cause other problems. It's a tradeoff you need to consider.

If the figure is simple enough, it may be a good workaround, but keep an eye on the width of the frame and tick marks: they may be off.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.