save_plots: Save multiple plots to a single PDF

Description Usage Arguments Examples

View source: R/plot-utils.R

Description

Takes a list of plots and exports them to a single PDF with one plot per page.

Usage

1
save_plots(plot_list, filename)

Arguments

plot_list

List of plot objects. Can be any type as long as it has a print() output.

filename

Character string. Can also be specified as path.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
  library(ggplot2)

  # Generate list of plots
  mtcars_split <- split(mtcars, mtcars$cyl)
  plot_list <- lapply(mtcars_split, function(d) {
    ggplot(d, aes(mpg, wt)) +
      geom_point()
  })

  # Save plots
  save_plots(plot_list, "plots.pdf")

## End(Not run)

milanmlft/MMmotley documentation built on Feb. 4, 2022, 7:42 a.m.