[R] Reducing the size of pdf graphics files produced with R

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Feb 7 12:47:07 CET 2008


hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

On Thu, 2008-02-07 at 11:52 +0100, Paul Hiemstra wrote:
> Hi all,
> 
> Maybe a bit late, but I found a way that worked great for me.
> 
> In windows, download CutePDF
> In linux (debian for me), install CUPS and cups-pdf
> 
> Open your pdf with a viewer and print to CutePDF or cups-pdf. Both 
> support a range of compression options. I use cups-pdf and reduced an R 
> output file of 3.6 mb to 0.9 mb. Much better if you want to include in a 
> Latex article

An alternative on Windows and Linux is GSView and Ghostscript:

http://pages.cs.wisc.edu/~ghost/gsview/

Using the convert option (File menu) one can use the pdfwrite driver and
set (under properties) CompressPages to TRUE. You can tweak a lot of the
PDF/Distiller preferences here as well.

G

> 
> cheers,
> Paul
> 
> Chabot Denis wrote:
> > Hi,
> >
> > Without trying to print 1000000 points (see <http:// 
> > finzi.psych.upenn.edu/R/Rhelp02a/archive/42105.html>), I often print  
> > maps for which I do not want to loose too much of coastline detail,  
> > and/or plots with 1000-5000 points (yes, some are on top of each  
> > other, but using transparency (i.e. rgb colors with alpha  
> > information) this actually comes through as useful information.
> >
> > But the files are large (not as large as in the thread above of  
> > course, 800 KB to about 2 MB), especially when included in a LaTeX  
> > document by the dozen.
> >
> > Acrobat (not the reader, the full program) has an option "reduce file  
> > size". I don't know what it does, but it shrinks most of my plots to  
> > about 30% or original size, and I cannot detect any loss of detail  
> > even when zooming several times. But it is a pain to do this with  
> > Acrobat when you generate many plots... And you need to buy Acrobat.
> >
> > Is this something the pdf device could do in a future version? I  
> > tried the "million points" example from the thread above and the 55  
> > MB file was reduced to 6.9 MB, an even better shrinking I see on my  
> > usual plots.
> >
> >
> > Denis Chabot
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >   
> 
> 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list