3
$\begingroup$
ClearAll[spiral];
spiral[n_?OddQ] := 
  Nest[With[{d = Length@#, l = #[[-1, -1]]}, 
     Composition[Insert[#, l + 3 d + 2 + Range[d + 2], -1] &, 
       Insert[#\[Transpose], l + 2 d + 1 + Range[d + 1], 
          1]\[Transpose] &, 
       Insert[#, l + d + Range[d + 1, 1, -1], 1] &, 
       Insert[#\[Transpose], 
          l + Range[d, 1, -1], -1]\[Transpose] &][#]] &, {{1}}, (n - 
      1)/2];

spiral[351] // PrimeQ // Boole // ArrayPlot
Export["Color351.pdf", %]

Code is from other post on the forum, credit to the OP. The question is, the exported PDF does not seem to have saved the graph in a lossless vector format.

This is what I get from the adobe acrobat:

enter image description here

If you go back and look at the picture from MMA10.2 X64 (win7), we can zoom in/out, the graph is still very sharp, in high resolution.

If there a way to save/export it with much higher quality?

Thanks.

$\endgroup$

1 Answer 1

4
$\begingroup$

I suspect that the fuzziness you see might not be caused by rasterization, but rather by antialiasing applied to the ArrayPlot markers. Anti-aliasing makes the edges of small graphical elements fuzzy to avoid jaggedness, and it is typically a good thing that generates visually pleasing results. In your case, however, the very small plot markers present in a default sized ArrayPlot get antialiased to this shape, when looking at the PDF generated by your code under maximum zoom:

enter image description here

Note that this effect is not visible in MMA if I zoom in to the plot, as the plot is evidently redrawn at the appropriate dimensions after zooming, and the effects of anti-aliasing are not as prominent on larger features.


I was able to get crisper results simply by requesting a larger output from ArrayPlot, and then exporting that:

spiral[351] // PrimeQ // Boole // ArrayPlot[#, ImageSize -> Large] &
Export["Color351Large.pdf", %]

Here is the a blown-up view of a similar portion of the graph from the exported "Color351Large.pdf":

enter image description here

$\endgroup$
2
  • $\begingroup$ In terms of visual, the blow-up version does look much better now. Purely for the sake of the question, is there an easy way to get the graph as a vector format? Your version in the default scale looks a bit fuzzy, especially at the edges since the graph is still exported as an "image". $\endgroup$ Commented Sep 17, 2015 at 5:52
  • $\begingroup$ @ChenStatsYu I am not in front of my computer now, so I will have to check more carefully tomorrow, but I am quite convinced that the exported graph in the PDF was in fact in vector format already. Maybe you could upload an image of the fuzzy part you see. Alternatively you could try exporting your graph as and EPS file. $\endgroup$
    – MarcoB
    Commented Sep 18, 2015 at 4:18

Your Answer

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

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