Size of plots in pdf files#can it be smaller?
Hi,
I've got a trial version of a thinScatter() function that
(down-)samples 2d-scatter plots while preserving the empirical density
distribution. You can grab it by:
source("http://www.braju.com/R/hbLite.R");
hbLite("scatterPlots");
Example from example(thinScatter):
library("scatterPlots");
# Sample scatter data
n <- 10e3
x <- rnorm(n=n)
y <- rnorm(n=n)
xy <- cbind(x=x, y=sin(x)+y/5)
layout(matrix(1:4, nrow=2, byrow=TRUE))
par(mar=c(5,4,2,1))
# Plot data
plot(xy, pch=1)
# Thin scatter data by subsampling
rhos <- c(1/3, 1/4, 1/6)
for (kk in seq(along=rhos)) {
xy2 <- thinScatter(xy, size=rhos[kk])
points(xy2, pch=1, col=kk+1)
title <- paste(sprintf("%.1f%%", 100*c(1, rhos)), collapse=", ")
mtext(side=3, line=0, paste("Densities:", title))
}
for (kk in seq(along=rhos)) {
xy2 <- thinScatter(xy, size=rhos[kk])
plot(xy2, pch=1, col=kk+1)
mtext(side=3, line=0, sprintf("Density: %.1f%% [n=%d]",
100*rhos[kk], nrow(xy2)))
}
If the mailing list allows it, a PNG is attached.
/Henrik
On Mon, Sep 7, 2009 at 1:50 PM, Philipp Pagel<p.pagel at wzw.tum.de> wrote:
I have to produce arrangements of 25 simple plots of the type plot(x,y,pch=".") where there are typically on the order of 20000 points. So, overall, I have about 500000 points. When I use the pdf device, I get file sizes (on a Windows machine) of about 10 MB. When I then zip the files, I'm down to about 0.5MB, so the original pdf files were created with a lot of 'air'. I'm wondering why the pdf files are so large and whether there is an alternative to produce them smaller. Any ideas?
As far as I know, R cannot directly produce compressed pdf files. You could postprocess your plots. E.g. pdftk is quite conveniant: pdftk foo.pdf cat output foo2.pdf compress Maybe in a loop if many files are involved. cu ? ? ? ?Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/
______________________________________________ R-help at r-project.org 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.
-------------- next part -------------- A non-text attachment was scrubbed... Name: thinScatter,Rex.png Type: image/png Size: 19567 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090907/9a0a0274/attachment-0002.png>