10
$\begingroup$

When I try to export some Graphics3D, like this one:

Mathematica graphics

into a PDF file I get a bad appearance like this:

enter image description here

It's possible to fix?

Steps to reproduce the problem:

nb = NotebookOpen["paclet:FEMDocumentation/ref/HexahedronElement", 
   Visible -> False];
g = Cases[
   NotebookRead /@ Cells[nb, CellStyle -> {"Notes", "Picture"}], 
   b : (_GraphicsBox | _Graphics3DBox) :> ToExpression@b, \[Infinity]];
g = GraphicsRow@DeleteCases[g, Graphics[Inset[_Graphics3D, ___], ___]]
NotebookClose[nb]
Export["test.pdf", g];
SystemOpen["test.pdf"]

and to cleanup

DeleteFile["test.pdf"]
$\endgroup$
4
  • $\begingroup$ Nice touch to provide clean-up ☺. Is rasterizing and exporting acceptable? This would be the straightforward, if not elegant route. $\endgroup$ – Yves Klett Feb 28 '16 at 12:06
  • $\begingroup$ @YvesKlett Thanks. No, rasterizing is not an option at present. Hope to find a vector way... $\endgroup$ – unlikely Feb 28 '16 at 12:10
  • $\begingroup$ I have slightly better results with this strategy How to export this PDF figure with a small size on 10.0 for Mac OS X x86 (64-bit) (December 4, 2014) $\endgroup$ – user9660 Feb 28 '16 at 14:29
  • $\begingroup$ on 10.3.1 for mac (10.8.5) I have no problem whatsoever. I do remember had similar problems when exporting contour plots to pdf so I may have updated the ghostscript libraries or so. $\endgroup$ – tsuresuregusa Feb 28 '16 at 14:45
2
$\begingroup$

This is an extended comment. Sorry, for not providing a solution. However, I hope that by knowing the reasons a solution can be found. In fact, this problem is not of Mathematica, but is of much more general nature and it is well-known in the graphical design community under the name of conflation artifacts. Several years ago, there has been an extremely popular post at the graphic design SE Is there a reason Hillary Clinton's logo has hidden notches? From the answer to this post, one realizes that artifacts can appear when two polygons touch each other.

Consider your case. All polygons are black, but have different levels of opacity: 10%, 20%, and 30%. If the rendering engine decides that there is a 1px overlap between, say two 10% and 10% polygons, a line with 20% opacity appears. The only solution is to merge polygons (the notches as in the logo are unfeasible). One can attempt to do it with Mathematica. Or one can post-process the figure in Adobe Illustrator (or Inkscape). It takes just a few clicks.

I anticipate a question, if there are really 1px overlaps in the figure. No, there are no overlaps, Mathematica is doing a good job here. However, the computer screen graphics is intrinsically discrete, whereas the coordinates of the polygon boundaries are in general real numbers. Therefore, the graphic engine needs to make some compromises.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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