Reduce PDF File Size of Plots by Filtering Hidden Objects

Reduce PDF file size of plots by filtering hidden objects

As a start you can do something like this:

set.seed(42)
DF <- data.frame(x=x<-runif(1e6),y=x+rnorm(1e6,sd=0.1))
plot(y~x,data=DF,pch=".",cex=4)

Sample Image

PDF size: 6334 KB

DF2 <- data.frame(x=round(DF$x,3),y=round(DF$y,3))
DF2 <- DF[!duplicated(DF2),]
nrow(DF2)
#[1] 373429
plot(y~x,data=DF2,pch=".",cex=4)

Sample Image

PDF size: 2373 KB

With the rounding you can control how many values you want to remove. You only need to modify this to handle the different colours.

Writing printer friendly pdfs with ggplot2 and many ( 25000) dots or lines

The only solution I found so far is the following: https://helpx.adobe.com/acrobat/kb/quick-fix-print-pdf-image.html

I think this might be the best way since the creation of PDF is the same, you just switch to "print as image" in the advance printing dialog in Acrobat Reader...



Related Topics



Leave a reply



Submit