[R] Plots - several pages per pdf - quality/size issue

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Thu Apr 23 16:56:22 CEST 2009


> I hope that question will not be too redundant (sorry if it is) but 
> i don't seem able to find the answer i need in the archives...
> 
> I try to create a file which would have 1.several pages and 2.
> several plots by page. I know how to make a pdf file this way, but 
> my problem is that the pdf size gets way too big and cannot be open.
> 
> So my question is:
> - is there a way to diminish the pdf size/quality?
> - does any other file format exists that would be of smaller quality
> but still be able to print plots on several pages for the same file?

You could try postscript instead. e.g.

p1 <- xyplot(runif(10000)~rnorm(10000)|sample(letters[1:3], 10000, 
replace=TRUE), layout=c(1,1))

pdf("test.pdf")
print(p1)
dev.off()
# File size 623kb

postscript("test.ps")
print(p1)
dev.off()
# File size 257kb

The other alternative is to print to a raster format, e.g. png.  this 
creates different files for different pages, but you could always find a 
way to view multiple plot files at once.  Some possibilities:
1. Use, e.g.,  Picasa to browse your plot files.
2. Create a simple webpage containing each image

# R code
png("test%d.png")
print(p1)
dev.off()

# Web page code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<img alt="first plot" src="test1.png" /> 
<img alt="second plot" src="test2.png" />
<img alt="third plot" src="test3.png" />
</body>

# File sizes 3*13kb + 1kb

Open and save this file in a word processor of your choice, and you can 
probably drop the file size even further.

Regards,
Richie.

Mathematical Sciences Unit
HSL



------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}




More information about the R-help mailing list