drmariod
drmariod

Reputation: 11762

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

I am creating a lot of facet plots with ggplot2 and writing those into a multiple page pdf file. I added some sample data as an example.

reps <- 1000
df <- data.frame(id=rep(letters[1:25], each=reps),
                 group=rep(LETTERS[1:25], each=reps),
                 x=runif(reps*25),
                 y=runif(reps*25))
pdf('test.pdf', width=11.69, height=8.27)
for(i in seq(4)) {
  p <- ggplot(df, aes(x,y, group=group)) +
    geom_line() + geom_point() +
    facet_wrap(~ id)
  print(p)
}
dev.off()

To view the PDF it is really nice, but most of the time these big files with vector graphics kill my print jobs.

Is there a way to handle this properly? For example, creating PNG images and saving them in multipage PDFs? Or, am I the only one having problems printing such files?

I am aware that the PNG file might be bigger, but I guess the printer can handle it much better than a vector graphic.

Upvotes: 2

Views: 304

Answers (1)

drmariod
drmariod

Reputation: 11762

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...

Upvotes: 1

Related Questions