Google Groups

Re: reduce size of eps files of 3D figures

JUN Mar 30, 2012 2:35 AM
Posted in group: comp.soft-sys.math.mathematica
On Thursday, March 29, 2012 2:10:01 AM UTC-7, Michael A. Morrison wrote:
> For a book I am writing, I am generating a lot of 3D figures using, for
> example, Graphics3D. Many of the resulting Exported *.eps files are huge,
> even for a simple case such as a row of three objects such as
> Graphics3D[Sphere[]]. These figures will not be printed in color. Is there a
> way to generate *.eps files for such a situation that are smaller than those
> Exported if one does nothing special? Many thanks in advance. --- michael

here is a new trick that I recently stumbled upon in Mathematica 8: to make Mathematica export all 3D graphics in your notebook in a very efficient way, just execute the following before creating the plots:

    Prolog -> {{EdgeForm[], Texture[{{{0, 0, 0, 0}}}],
       Polygon[#, VertexTextureCoordinates -> #] &[{{0, 0}, {1,
          0}, {1, 1}}]}}] &, {Graphics3D, ContourPlot3D,
   ListContourPlot3D, ListPlot3D, Plot3D, ListSurfacePlot3D,
   ListVectorPlot3D, ParametricPlot3D, RegionPlot3D, RevolutionPlot3D,
    SphericalPlot3D, VectorPlot3D}];

This creates an invisible triangle (with a transparent texture) and adds it as a Prolog to all 3D plotting functions. The mere presence of this invisible element forces Mathematica to give up trying to export EPS and PDF versions made of individual polygons. That's the reason for the large file size. Instead, it decides to use a high-resolution rasterization of your plot and embeds it into the EPS file. I chose to use the Prolog option for this trick because I'm assuming it's rarely used with 3D graphics.

With this, you need to make no changes to any of your subsequent Export commands - the simple form Export["file.eps", plot] will work fine.

More discussion of this (and an example where the file size is reduced rom 200 MByte to 400KByte) is found here: