export_plot: Save a plot in a variety of formats with a single call

View source: R/export_plot.R

export_plotR Documentation

Save a plot in a variety of formats with a single call

Description

Convenient for keeping plots at the ready for presentations, papers, social media, etc.

Usage

export_plot(
  x,
  dirs = c("figs", "presentations/presentation-figs"),
  formats = c("png", "pdf"),
  rds = FALSE,
  ...
)

Arguments

x

ggplot object to save. The file name is automatically populated from the object's name.

dirs

directories in which to save the plots, defaults to 'figs' and 'presentations/presentation-figs', i.e. a directory named 'figs' located in the top level of current working directory and another one specifically for SVG versions of R plots used for HTML slide sets.

formats

character. Image-based file formats to include. Allowed formats include 'svg', 'png', and 'pdf'.

rds

Logical. Save also in binary .rds format? (Default FALSE; useful for building R Markdown documents; the plots can be iteratively imported into a list and easily called with code rather than individual file paths)

...

Other arguments passed to cowplot::save_plot()

Value

Writes files to disk and prints a message if successful


evanmascitti/ecmfuns documentation built on April 5, 2025, 1:52 a.m.