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

export eps

137 views
Skip to first unread message

jame...@googlemail.com

unread,
Jul 19, 2008, 4:51:07 AM7/19/08
to
hi

I have a graph generated with ContourPlot3D.

when I try to export it as eps, the eps file is 50MB size.

I need to use the eps image in Latex.

how to solve this problem

Jens-Peer Kuska

unread,
Jul 20, 2008, 6:57:52 AM7/20/08
to
Hi,

since you don't give us an example I can only try to reduce the size
with my own example

plt = ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi}];
FileInformation[Export["i:/temp/ctest.eps", plt]]

gives
{File -> "I:\\temp\\ctest.eps", FileType -> File, Date -> 3425476087,
ByteCount -> 2688623}

while

plt1 = ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi},
MaxRecursion -> 0, PlotPoints -> 64,
Method -> {"Refinement" -> {"CellDecomposition" -> "Quad"}}]
FileInformation[Export["i:/temp/ctest1.eps", plt1]]


gives

{File -> "I:\\temp\\ctest1.eps", FileType -> File, Date -> 3425476179,
ByteCount -> 679263}

the last file is nearly 4 times smaller

and

plt2 = ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi},
MaxRecursion -> 0, PlotPoints -> 32,
Method -> {"Refinement" -> {"CellDecomposition" -> "Quad"}}];
FileInformation[Export["i:/temp/ctest2.eps", plt2]]

gives a nearly 9 times smaller *.eps file.

So you have to play around a with the PlotPoints and MaxRecursions
option.

How ever since the refinement is adaptive, the size reduction depend on
the function you try to plot.

Hope that helps
Jens

Jean-Marc Gulliet

unread,
Jul 20, 2008, 6:58:25 AM7/20/08
to
jame...@googlemail.com wrote:

That all depends on what your plot actually is. Usually, when a graph is
too large, it is a good idea to control the adaptive sampling thanks to
the options *PlotPoints* and *MaxRecursion* (see the online help for
more details). Below are two examples of the influence of these options
on the size of the resulting graphs.

Module[{g},
Grid[Table[g = ContourPlot3D[Sin[3*x]*Sin[3*y]*Sin[3*z] == 1/2,
{x, 0, 3}, {y, 0, 3}, {z, -1, 1}, Mesh -> None,
BoxRatios -> Automatic, PlotPoints -> pp, MaxRecursion -> mr];
Export["g.eps", g]; Print["Points: ", pp, ", Recursions: ", mr,
", File Size (MB): ", N[FileByteCount["g.eps"]/2^20]]; g,
{pp, {5, 10}}, {mr, {0, 2}}]]]

Points: 5, Recursions: 0, File Size (MB): 0.0848265

Points: 5, Recursions: 2, File Size (MB): 5.90143

Points: 10, Recursions: 0, File Size (MB): 0.201566

Points: 10, Recursions: 2, File Size (MB): 22.4477


Module[{g},
Grid[Table[g = ContourPlot3D[x^4 + y^4 + z^4 - (x^2 + y^2 + z^2)^2
+ 3*(x^2 + y^2 + z^2) == 3, {x, -2, 2}, {y, -2, 2}, {z, -2, 2},
Mesh -> None, ContourStyle -> Directive[Orange, Opacity[0.8],
Specularity[White, 30]], PlotPoints -> pp, MaxRecursion -> mr];
Export["g.eps", g]; Print["Points: ", pp, ", Recursions: ", mr,
", File Size (MB): ", N[FileByteCount["g.eps"]/2^20]]; g,
{pp, {20, 40}}, {mr, {0, 2}}]]]

Points: 20, Recursions: 0, File Size (MB): 1.73392

Points: 20, Recursions: 2, File Size (MB): 4.47856

Points: 40, Recursions: 0, File Size (MB): 7.84393

Points: 40, Recursions: 2, File Size (MB): 19.5442


Regards,
-- Jean-Marc


J Davis

unread,
Jul 21, 2008, 4:28:36 AM7/21/08
to
On Jul 20, 5:58 am, Jean-Marc Gulliet <jeanmarc.gull...@gmail.com>
wrote:

> james...@googlemail.com wrote:
> > I have a graph generated with ContourPlot3D.
>
> > when I try to export it aseps, theepsfile is 50MB size.
>
> > I need to use theepsimage in Latex.

>
> > how to solve this problem
>
> Usually, when a graph is
> too large, it is a good idea to control the adaptive sampling thanks to
> the options *PlotPoints* and *MaxRecursion*

Yes, Jean-Marc, but what if one is not setting PlotPoints nor
MaxRecursion to an unusually high number? What to do then about these
large graphics files?

IMO, this is a very dissatisfying unresolved "feature" of v6 over 5
that I am very surprised (and disappointed) has not been resolved at
this late date.

When I "Save Selection As..." either PDF or EPS of a simple

Plot3D[Sin[x^2+y^2],{x,-2,2},{y,-2,2}]

I get PDF's that are about 700K and EPS that are almost 4 mb. These
are huge file sizes---especially relative to how small these files
were in v5.

Ugh.

Will Robertson

unread,
Jul 22, 2008, 4:01:20 AM7/22/08
to
On 2008-07-21 17:58:36 +0930, J Davis <texasA...@gmail.com> said:

> When I "Save Selection As..." either PDF or EPS of a simple
>
> Plot3D[Sin[x^2+y^2],{x,-2,2},{y,-2,2}]
>
> I get PDF's that are about 700K and EPS that are almost 4 mb. These
> are huge file sizes---especially relative to how small these files
> were in v5.

Hi J,

Check out the fixpolygons package:
<http://library.wolfram.com/infocenter/MathSource/7029/>
It's a package I wrote that was subsequently re-written & improved by
my co-author to fix this exact problem. Not only are the graphics huge,
they display very poorly on-screen and when printed.

The problem is that the Mathematica graphic contains every polygon used
in the mesh to generate the plot, even if they are the same colour and
next to each other. The package provides a function that literally just
merges these adjacent polygons into one. It's not exactly lightning
quick, however.

Hope this helps,
Will


Alberto Verga

unread,
Jul 22, 2008, 4:01:31 AM7/22/08
to
On Jul 21, 10:28 am, J Davis <texasAUti...@gmail.com> wrote:
> On Jul 20, 5:58 am, Jean-Marc Gulliet <jeanmarc.gull...@gmail.com>
> wrote:
>
> > james...@googlemail.com wrote:
> > > I have a graph generated with ContourPlot3D.
>
> > > when I try to export it aseps, theepsfile is 50MB size.
>
> > > I need to use theepsimage in Latex.

>
> > > how to solve this problem
>
> > Usually, when a graph is
> > too large, it is a good idea to control the adaptive sampling thanks to
> > the options *PlotPoints* and *MaxRecursion*
>
> Yes, Jean-Marc, but what if one is not setting PlotPoints nor
> MaxRecursion to an unusually high number? What to do then about these
> large graphics files?
>
> IMO, this is a very dissatisfying unresolved "feature" of v6 over 5
> that I am very surprised (and disappointed) has not been resolved at
> this late date.
>
> When I "Save Selection As..." either PDF or EPS of a simple
>
> Plot3D[Sin[x^2+y^2],{x,-2,2},{y,-2,2}]
>
> I get PDF's that are about 700K and EPS that are almost 4 mb. These
> are huge file sizes---especially relative to how small these files
> were in v5.
>
> Ugh.

Indeed, the simple
p3D=Plot3D[Sin[x^2+y^2],{x,-2,2},{y,-2,2}]
Export["p3D.pdf",p3D]
gives you an unusable .pdf:
The exported file contains lots of spurious white polygons filling
flat faces.
The only "work-around" I've found is to export in bitmap (.png for
instance) and then convert it to pdf or eps (?!)

A. Verga


Peter Breitfeld

unread,
Jul 22, 2008, 4:02:03 AM7/22/08
to
This may be a little off topic:
I browsed through the documentation, but could not find which
Methods are possible and what they mean. Can anyone give me a hint
where all possible setting of Method are listed including a
description of their meaning?


Jens-Peer Kuska schrieb:

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

David Park

unread,
Jul 22, 2008, 4:02:14 AM7/22/08
to
There is a big difference between using SaveAs a .pdf file say, and Printing
to the Adobe PDF printer with an up-to-date Adobe Acrobat! When I do
Jens-Peer's first example:

ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi}]

using the Print to Adobe PDF printer, with Adobe Acrobat 8, I obtain a file
that is 49 KB in size.

The Mathematica SaveAs .pdf command produces huge files of very poor
quality. For example, for another test I did with a small notebook, the
SaveAs command produced a pdf file of 1,762 KB (and very poor quality)
compared to 85 KB for the Print to Adobe PDF command.

I don't know why that is.

--
David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/


<jame...@googlemail.com> wrote in message news:g5s9tr$557$1...@smc.vnet.net...

jame...@googlemail.com

unread,
Jul 22, 2008, 4:03:51 AM7/22/08
to
Thank you to all of you for your appreciated help.

I have used both functions MaxRecursion and PlotPoints to get the
problem solved.

The resulting file is 1.30MB (the original one without using funtions
was 50MB).

Thanks.

AES

unread,
Jul 23, 2008, 6:19:17 AM7/23/08
to
In article <g64466$dim$1...@smc.vnet.net>,
"David Park" <djm...@comcast.net> wrote:

>
> ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi}]
>
> using the Print to Adobe PDF printer, with Adobe Acrobat 8, I obtain a file
> that is 49 KB in size.
>
> The Mathematica SaveAs .pdf command produces huge files of very poor
> quality. For example, for another test I did with a small notebook, the
> SaveAs command produced a pdf file of 1,762 KB (and very poor quality)
> compared to 85 KB for the Print to Adobe PDF command.
>
> I don't know why that is.
>
> --
> David Park

David, could you give a bit more detail about the sequence of steps
you're following here?

In particular, are you starting with an existing PDF file already on
your hard disk (which came from Mathematica originally somehow, and is
"bad"); opening that PDF file in Acrobat; then Printing it to PDF, from
Acrobat, into a _new_ (and good) PDF file?

Or are you Printing to a PDF file _from Mathematica itself_ to get the
good file?

In my case, I'm on a Mac. On a Mac, you can print an open document to a
PDF file from almost any Mac application (including Mathematica), using
a print to PDF capability which I believe is part of the Mac OS, and is
called or used by all these applications.

But, this built-in Mac capability can not be used from Acrobat (Acrobat
7 in my case) -- it's disabled. Instead, Acrobat just tells me to use
the Acrobat "Fo\ile >> Save" menu command -- and I'm skeptical that just
Saving a bad file that was Opened in Acrobat will convert it into a good
file, or change it in any way.

And I'm not finding any other "Print to PDF" command elsewhere in the
version of Acrobat on my Mac . . . ? (There is a "Reduce File Size"
command -- but I my impression is that it mostly strips out stuff having
to do with earlier versions of PDF, or duplicate stuff, and is not
sophisticated enough to dig within 3D graphics content and eliminate
duplicate polygons.)

J Davis

unread,
Jul 23, 2008, 6:20:53 AM7/23/08
to
On Jul 22, 3:02 am, "David Park" <djmp...@comcast.net> wrote:
> There is a big difference between using SaveAs a .pdf file say, and Printing
> to the Adobe PDF printer with an up-to-date Adobe Acrobat! When I do
> Jens-Peer's first example:
>
> ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi}]
>
> using the Print to Adobe PDF printer, with Adobe Acrobat 8, I obtain a file
> that is 49 KB in size.
>
> The Mathematica SaveAs .pdf command produces huge files of very poor
> quality. For example, for another test I did with a small notebook, the
> SaveAs command produced a pdf file of 1,762 KB (and very poor quality)
> compared to 85 KB for the Print to Adobe PDF command.
>
> I don't know why that is.
>
> --
> David Park

Thanks, David (and other who responded with solutions above. I will
try them soon.

I hope this is something Wolfram will address soon. It is too
fundamental to ignore, IMO...

John

Will Robertson

unread,
Jul 23, 2008, 6:22:40 AM7/23/08
to
On 2008-07-22 17:32:14 +0930, "David Park" <djm...@comcast.net> said:

> There is a big difference between using SaveAs a .pdf file say, and Pri=
nting


> to the Adobe PDF printer with an up-to-date Adobe Acrobat! When I do

> Jens-Peer's first example [...] using the Print to Adobe PDF printer,


> with Adobe Acrobat 8, I obtain a file that is 49 KB in size.

Interesting! This is good evidence that FixPolygon's technique could be
improved and integrated directly into Mathematica's Export.

Now the next questions are:
(a) how to do this programatically (and in my student copy of the
program, at least, the PDF needs post-processing to remove a "Printed
by Mathematica" banner and crop the margins), and
(b) if it's possible to use the same technique to get high quality
EPS files too.

Best regards,
Will


Curtis Osterhoudt

unread,
Jul 24, 2008, 4:52:35 AM7/24/08
to
On Wednesday 23 July 2008 03:57:42 J Davis wrote:
> On Jul 22, 3:02 am, "David Park" <djmp...@comcast.net> wrote:
> > There is a big difference between using SaveAs a .pdf file say, and
> > Printing to the Adobe PDF printer with an up-to-date Adobe Acrobat! When
> > I do Jens-Peer's first example:
> >
> > ContourPlot[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi}]
> >
> > using the Print to Adobe PDF printer, with Adobe Acrobat 8, I obtain a
> > file that is 49 KB in size.
> >
> > The Mathematica SaveAs .pdf command produces huge files of very poor
> > quality. For example, for another test I did with a small notebook, the
> > SaveAs command produced a pdf file of 1,762 KB (and very poor quality)
> > compared to 85 KB for the Print to Adobe PDF command.
> >
> > I don't know why that is.
> >
> > --
> > David Park
>
> Thanks, David (and other who responded with solutions above. I will
> try them soon.
>
> I hope this is something Wolfram will address soon. It is too
> fundamental to ignore, IMO...
>
> John

So far as I can tell, using "Save Selection As" and "Print to... PDF file"
give file sizes which are the same (within several kB for a ~ 1.4 MB file).
However, this is using Linux, and not the OS X's nifty "print anything to
a .pdf" ability. Opening either file using Acrobat (or other .pdf readers)
gives quite a pause as all of the constituent polygons are drawn and filled.

Does anyone else using any Linux get the file sizes radically different?

Regards,
C.O.

--
==========================================================
Curtis Osterhoudt
cfo@remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================

Will Robertson

unread,
Jul 24, 2008, 4:52:46 AM7/24/08
to
On 2008-07-23 19:49:17 +0930, AES <sie...@stanford.edu> said:

> Or are you Printing to a PDF file _from Mathematica itself_ to get the
> good file?
>
> In my case, I'm on a Mac.

Me too. "Print to Selection" brings up a standard print dialog, from
which you can save to PDF with the Apple "distiller". The resulting PDF
isn't quite as small as the Acrobat-generated one (seemingly -- I don't
have it) but the quality is very good and the file size is definitely
small enough.

Cheers,
Will


0 new messages