0

I'd like to put several plots into one PDF, with a new page for each plot. Each plot is generated with ggplot, and each needs a different scale.

I know how to output individual plots into individual PDFs at the appropriate scale, like so:

plot1 <-
ggplot(mtcars, aes(x=hp, y=mpg)) +
  geom_point()
ggsave(file="plot1.pdf", plot=plot1, scale=3)

plot2 <-
  ggplot(mtcars, aes(x=wt, y=hp)) +
  geom_point()
ggsave(file="plot2.pdf", plot=plot2, scale=1)

I also know how to put multiple plots into one PDF, with each plot on a separate page, like so:

# Open PDF to save all plots to
pdf(file="plots.pdf")

# Print plots to the pdf
print(plot1)
print(plot2)

# Turn off PDF plotting
dev.off()

However, what I can't work out is how to give each individual plot within the PDF a different scale?

benson23
  • 16,369
  • 9
  • 19
  • 38
Mike
  • 921
  • 7
  • 26
  • Yes, none seem to be able to change the scale of individual plots. egs coming ... – Mike Feb 21 '22 at 21:06
  • Sorry, was meant to be https://stackoverflow.com/questions/12234248/printing-multiple-ggplots-into-a-single-pdf-multiple-plots-per-page – Mike Feb 21 '22 at 21:15
  • https://gist.github.com/Rekyt/a7846af7c4c5fb5a48ea – Mike Feb 21 '22 at 21:17
  • https://www.datanovia.com/en/blog/how-to-save-a-ggplot/#save-ggplot-into-a-pdf-file – Mike Feb 21 '22 at 21:18
  • https://stackoverflow.com/questions/38858830/how-to-get-plots-in-several-pdf-pages-using-ggplot2/38859493 – Mike Feb 21 '22 at 21:19

0 Answers0