Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce size of plots in EPS format

Tags:

r

eps

postscript

I have a histogram with several hundred items, for which I do a Q-Q plot. This results in EPS that is 2.5 megabytes large. This is too much for a figure that is only going to be included in a publication and is not going to be viewed at 100x magnification.

Is there any option in R to somehow output smaller EPS? I have searched docs to no avail. Or is my best option to, say, rasterize it afterwards at 300 dpi? If that's the case, any recommendations for the tool for this job?

The R code for the plot is nothing fancy:

postscript(filename)
qqnorm(n, main=title))
qqline(n)
dev.off()

EDIT: Doh! My question mentioned outputting EPS, and then converting it to some raster format. When of course I could just generate PNG in the first place from R.

like image 934
Laurynas Biveinis Avatar asked Jul 22 '09 07:07

Laurynas Biveinis


People also ask

How do I reduce EPS file size?

Preferred Method for Saving EPS Files For vectors containing transparencies, set the Raster/Vector Balance to 0 and the Resolution settings to 72 ppi in order to dramatically reduce your file size.

Can you compress an EPS file?

That said, there are a few things you can do, to make an EPS file smaller: convert all fonts to outlines and/or uncheck "Embed Fonts" in save dialog. simplify path detail ( Object >> Path >> Simplify ) Keep fancy bitmap effects (like shadows and transparency) to a minimum.

What size should EPS file be?

Resolution Files submitted for digital offset printing should be 400 DPI (dots-per-inch) at the actual size that they will be used. A 4.25 X 6.25 photoshop EPS file in CMYK mode should be 16.2 megabytes. Anything over 400 DPI will be discarded.

How do I edit an EPS file in Word?

Go to the file selection area and change All Graphics Files to All Files. Word will convert the EPS file and then insert it into the Word file.


1 Answers

I've just tried several things that didn't work - I'm including them here to save others wasting their time. For reference, I set n <- rnorm(1e5) in your code above.

Things that don't work:

  1. Setting colormodel <- "gray".

  2. Using a different value of pch. (Some other values increase the file size, but I found none that decrease it.)

  3. Setting useKerning = FALSE.

  4. Changing the width and height settings.

  5. Using pdf instead of postscript.

  6. Using CarioPS from the Cairo package.

In the light of this, I think that you are unlikely to be able to decrease the file size using a vector format. This means that you will have to use a raster format (most likely PNG).

like image 71
Richie Cotton Avatar answered Sep 24 '22 04:09

Richie Cotton