Skip to contents

Save a list of plots to multipage PDF.

Usage

save_pdf(
  plots,
  output_file,
  width = NULL,
  height = NULL,
  make_thumbnail = FALSE,
  stop_on_error = FALSE
)

Arguments

plots

A list of plots.

output_file

A character scalar: path to output PDF file. If file's directory doesn't exist, it will be created recursively.

width, height

A numeric scalar: default width and height of graphics region in inches. Defaults to 7.

make_thumbnail

A logical scalar: if TRUE, a PNG file will be created from the first plot in plots.

stop_on_error

A logical scalar: if TRUE, the function will stop when there is an error during the saving of the plot. Otherwise a dummy PDF/PNG thumbnail file with error description will be created instead.

Value

A named list with the following items:

  • success: a logical scalar indicating whether the plot saving succeeded (TRUE) or not (FALSE).

  • error: a character scalar with error message if success is FALSE, NULL otherwise.

  • error_plot: a ggplot2 object with error plot if success is FALSE, NULL otherwise.

  • output_file: a character scalar, identical to output_file parameter.

  • thumbnail_file: a character scalar, path to thumbnail PNG file if make_thumbnail is TRUE, NULL otherwise.

Note that success of FALSE and the accompanying error message and plot are only possible when stop_on_error is FALSE.