Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

best way to save 3D plot as .eps for latex document?

402 views
Skip to first unread message

summer

unread,
Jul 20, 2009, 5:59:50 AM7/20/09
to
I have to put a 3D Mathematica plot in a latex document so I save the plot by right clicking it and saving as .eps. The problem is that if I save as vector graphics the file is 14MB, if I save as BMP inside the eps, the file is 2MB still too big and it takes too much time each time I'm recompiling the file.

Is there a way to efficiently save the plot as .eps so that
1. the file is small
2. quality is still acceptable
3. recompiling the latex is fast

What are the necessery steps/settings that work best for that?

Peter Breitfeld

unread,
Jul 20, 2009, 7:20:04 PM7/20/09
to
summer wrote:

The best (?) way I found is to use "PrintSelection" and to print it into
a .pdf file. Then take a Graphics Program (on my Mac I use
GraphicsConverter for this) and save it as a .eps. This gives good
looking graphics of very moderate size.

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

Mark McClure

unread,
Jul 20, 2009, 7:20:57 PM7/20/09
to
On Mon, Jul 20, 2009 at 6:01 AM, summer <summ...@hotmail.com> wrote:

> I have to put a 3D Mathematica plot in a latex document so I save the plot

> by right clicking it and saving as .eps. ...


>
> Is there a way to efficiently save the plot as .eps so that
> 1. the file is small
> 2. quality is still acceptable
> 3. recompiling the latex is fast

Of course, the answer will depend, in part, on the specific graphics you
are rendering. Here's a specific example, for context.

p[r_, t_] := {r*Cos[t], r*Sin[t], Sin[-r^2]};
pic = ParametricPlot3D[p[r, t], {r, 0, Pi/2}, {t, 0, 2 Pi}]

If pic is then exported to EPS, the file size is nearly 4MB. I suppose
the file size is so large since the adaptive plotting procedures produce
a large number of points. I suppose the mesh doesn't look so good after
export to PDF since the mesh lines are generated independently of the
polygons.

An easy fix is to turn off the adaptive plotting procedures by setting
MaxRecusion->0 and to force the mesh lines to be right at the polygonal
edges by specifying Mesh->All.

p[r_, t_] := {r*Cos[t], r*Sin[t], Sin[-r^2]};
pic = ParametricPlot3D[p[r, t], {r, 0, Pi/2}, {t, 0, 2 Pi},
Mesh -> All, MaxRecursion -> 0, PlotPoints -> {15, 40}]

The resulting EPS file is only 800K and the line quality is much better.
Unfortunately, the polygons are all triangulated so the Mesh might not
be what you want.

If you're willing to do a little graphics programming, you can get a
quite satisfying result. The key point is to generate a collection of
rectangular patches for your surface and to collect them into a
GraphicsComplex with SurfaceNormals specified.

p[r_, t_] := {r*Cos[t], r*Sin[t], Sin[-r^2]};
dr = Pi/30; dt = Pi/20;
polygons =
Table[Polygon[{p[r, t], p[r + dr, t], p[r + dr, t + dt], p[r, t + dt]}],
{r, 0, Pi/2 - dr, dr}, {t, 0, 2 Pi - dt, dt}];
points = Union[Flatten[polygons /. Polygon[{pp__}] -> pp, 1]];
multigon = Polygon[Flatten[polygons /.
Polygon[{pp__}] :> Flatten[Position[points, #] & /@ {pp}], 1]];
n[r_, t_] = Cross[D[p[r, t], r], D[p[r, t], t]];
vns = Join[{{{0, 0, 0}, {0, 0, 1}}},
Flatten[Table[{p[r, t], n[r, t]}, {r, dr, Pi/2, dr},
{t, 0, 2 Pi - dt, dt}], 1]];
vns = Last /@ SortBy[vns, First];
pic = Graphics3D[GraphicsComplex[points, multigon,
VertexNormals -> vns]]

It's clearly a bit more work, but this version is reasonably sized
at 800K and looks pretty nice after export.

Mark McClure


AES

unread,
Jul 20, 2009, 7:22:01 PM7/20/09
to
In article <h41f6m$rjc$1...@smc.vnet.net>, summer <summ...@hotmail.com>
wrote:

In my (admittedly limited) experience:

* PDF files are generally substantially smaller in size than EPS files
for the same graphic content, and easier to work with; and

* There are certainly implementations of TeX and LaTeX (I think most of
the newer ones?) that allow one to put PDF files directly into LaTeX
documents.

Maybe this is the direction in which to look?

The TUG users group and TUGboat are recommended sources of info.

rych

unread,
Jul 22, 2009, 6:18:30 AM7/22/09
to
Here is a thought.

* Export it as a 3D geometry file
* Use movie15 LaTeX package
* Acrobat Reader 7 and above can render embedded 3D content.
* Tell us why it wouldn't work

Filippo Miatto

unread,
Jul 24, 2009, 6:09:37 AM7/24/09
to

Until it's ready you can recompile it with the 'draft' option, so it
will use a blank rectangle in place of pictures.
it's much faster.
Filippo


On Jul 21, 2009, at 1:20 AM, Peter Breitfeld wrote:

> The best (?) way I found is to use "PrintSelection" and to print it
> into
> a .pdf file. Then take a Graphics Program (on my Mac I use
> GraphicsConverter for this) and save it as a .eps. This gives good
> looking graphics of very moderate size.
>
> --
> _________________________________________________________________
> Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
>

------------------------------------------------------------
Mobile (IT): +39 340 6104269
Home (IT): +39 0438 59360

Via Scossore, 94
31029 Vittorio Veneto (TV)
Italy

msn: dr.z...@hotmail.com
skype: filippo.miatto
Quantum Optics
Group Mail: mia...@molphys.leidenuniv.nl


0 new messages