Mathematica doesn't do the best job of exporting figures with shading or transparency to vector graphics formats such as PDF.

A common trick employed here and elsewhere on the web to workaround this is to rasterize just the image portion of the figure and insert this back into a vector version of the axes, labels etc.

The axes are typically converted to a vector drawing by the command:

ImportString[ExportString[axes, "EPS"]]

However this appears to no longer work on V11. More specifically I'm not sure ExportString[axes, "EPS"]] is behaving as it should, certainly it's output is very different between V10 and V11.

Complete test case:

fig = Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}]
axes = Graphics3D[{}, AbsoluteOptions[fig]]
ExportString[axes, "EPS"]

Outputs at pastebin:

V10, V11

The V10 output is all understandable and can be correctly imported via ImportString in both V10 and V11. However the V11 output contains what looks to be compressed data in the form

...g&[ie9oJbc5;SLF=49tG:f #EsI8)63Mg(KS!"/5i2neP :F"d@<>E99o

and cannot be imported by either V10 or V11.

So, am I missing something or is ExportString[...,"EPS"] not working correctly in V11?

If so, what is a suitable workaround?


Note also that simply exporting to an EPS figure via Export also does not produce a vector image.

The option "AllowRasterization -> False" does not help for either Export or ExportString however setting it to True results in an even more coarsely rasterized image!

Screenshot of a section of the V11 output to show formatting:

enter image description here

  • 1
    $\begingroup$ Dunno a workaround, but I'm for marking this as a bug. $\endgroup$
    – Pillsy
    Mar 1, 2017 at 15:37
  • 1
    $\begingroup$ Having spoken to Wolfram this is now a known issue, introduced in 10.4 and persisting to 11. $\endgroup$ Mar 8, 2017 at 20:19
  • $\begingroup$ OK, let's make it a bug then. $\endgroup$
    – Pillsy
    Mar 9, 2017 at 14:17
  • $\begingroup$ are all the backslashes terminating the line ends really in the mathematica string? There are two issues here, one the result is rasterized, two the result is corrupted by being wrapped to 70 columns. The backslash is not valid postscript. That may have happened on upload to pastebin though. $\endgroup$
    – george2079
    Mar 9, 2017 at 14:56
  • 1
    $\begingroup$ Jens' workaround works in version 11.0.1: ImportString[ExportString[Graphics[Inset[axes,Automatic,Automatic,Scaled[1]]],"PDF"],"PDF"]. But for "EPS" it kills the system taking all available physical memory (more than 6 GB before I killed Mathematica.exe)... $\endgroup$ Mar 9, 2017 at 21:11


Your Answer

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

Browse other questions tagged or ask your own question.