Write a list of plots (ggplots; as used by fasstr) into a directory or PDF document. When writing into a named directory each plot will be named by the plot name listed in the list; uses ggplot2::ggsave function. When writing into a PDF document (combined_pdf == TRUE) the plot names will not appear; uses grDevices::pdf function.

write_plots(
  plots,
  folder_name,
  plot_filetype,
  width,
  height,
  units = "in",
  dpi = 300,
  combined_pdf = FALSE
)

Arguments

plots

List of plots to write to disk.

folder_name

Name of folder to create on disk (if it does not exist) to write each plot from list. If using combined_pdf argument, then it will be the name of the PDF document.

plot_filetype

Image type to write. One of 'png', 'eps', 'ps', 'tex', 'pdf', 'jpeg', 'tiff', 'bmp', or 'svg'. Image type will be overwritten if using combined_pdf is used.

width

Numeric plot width in units. If not supplied, uses the size of current graphics device.

height

Numeric plot height in units. If not supplied, uses the size of current graphics device.

units

Character string plot height and width units, one of 'in', 'cm', or 'mm'. Default 'in'.

dpi

Numeric resolution of plots. Default 300.

combined_pdf

Logical value indicating whether to combine list of plots into one PDF document. Default FALSE.

Examples

if (FALSE) {

# Working examples:

# Example plots to save
plots <- plot_annual_lowflows(station_number = "08NM116")

# Write the plots as "png" files
write_plots(plots = plots, 
            folder_name = "Low Flow Plots",
            plot_filetype = "png")

# Write the plots as a combined "pdf" document
write_plots(plots = plots, 
            folder_name = "Low Flow Plots",
            combined_pdf = TRUE)
            
}