Created
November 7, 2023 15:26
-
-
Save swo/0c574830779c8e750307113cfe9f2f8f to your computer and use it in GitHub Desktop.
Make a multipage pdf with ggplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' @param list_of_plots plots to save, one per page | |
#' @param path path to output pdf | |
#' @param ... additional arguments to `ggplot2::ggsave()` | |
save_multipage_pdf <- function(list_of_plots, path, ...) { | |
# path must end with .pdf | |
stopifnot(grepl("\\.pdf$", path)) | |
ggplot2::ggsave( | |
path, | |
gridExtra::marrangeGrob(list_of_plots, ncol = 1, nrow = 1) | |
... | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment