export_ggplot: Function to export *ggplot2* plot, usually as a '.pdf' file.

View source: R/export_ggplot.R

export_ggplotR Documentation

Function to export ggplot2 plot, usually as a .pdf file.

Description

Function to export ggplot2 plot, usually as a .pdf file.

Usage

export_ggplot(
  file = NA,
  plot = ggplot2::last_plot(),
  width = 6,
  height = 5,
  crop = FALSE,
  to_png = FALSE,
  png_resolution = 320,
  device = NULL,
  verbose = FALSE
)

Arguments

file

File name to export plot to, usually as a .pdf file.

plot

ggplot2 object. If not used, the last plot will be retrieved.

width

Plot width in inches.

height

Plot height in inches.

crop

Should the output be cropped? systemr needs to be installed if TRUE.

to_png

Should the file be converted to a .png file too?

png_resolution

If to_png is TRUE, what resolution (in dpi) should be used?

device

Device to use. Use cairo_pdf (no quotes) to use the cairo library.

verbose

Should the function give messages?

Value

Invisible ggplot2 object.

Author(s)

Stuart K. Grange


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.