I'm trying to print multiple scatter plots each in one page, all in one file. So I print each scatter plot to a page in a pdf file. The problem is that because the scatter plot has too many data points, the pdf file is too large. I understand png will reduce the size of the file significantly, but it wouldn't be possible to put multiple png s in multiple pages of a single file, right? I thought the only way is to do it with pdf, now the pdf file is too large. Any idea how to deal with this? Thanks. Here is my code:
library(ggplot2)
df <- data.frame(x = rnorm(50000),y=rnorm(50000))
pdf("myPlots.pdf",onefile=TRUE)
for (i in 1:10)
print(ggplot(df,aes(x=x,y=y)) + geom_point())
dev.off()