ggfigsave: Output and save a ggplot object

View source: R/gg_figsave.R

ggfigsaveR Documentation

Output and save a ggplot object

Description

Outputs a ggplot object as a pdf with standard scientific journal settings, and saves and rds object

Usage

ggfigsave(
  ggdata,
  name = waiver(),
  path = waiver(),
  dpi = 600,
  width = 6.5,
  height = waiver(),
  aspect_ratio = 1,
  units = c("in", "cm", "mm", "px"),
  format = c("pdf", "png", "rds"),
  open = FALSE,
  overwrite = FALSE
)

Arguments

ggdata

ggplot2 object

name

Filename (optional, defaults to name of the input ggplot object)

path

Path of the directory to save plot to: path and filename are combined to create the fully qualified file name. Defaults to the working directory.

dpi

Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types.

width

Plot size in units ("in", "cm", "mm", or "px"). If not supplied, uses the size of current graphics device.

height

Plot size in units ("in", "cm", "mm", or "px"). If not supplied, uses the size of current graphics device.

aspect_ratio

Ratio of width to height. Default = 1.

units

Plot size in units ("in", "cm", "mm", or "px"). If not supplied, uses the size of current graphics device.

format

Output file format, any of "rds", "pdf", "eps", "ps", "tex", "jpeg", "tiff", "png", "bmp", "svg".

open

Open the image file after creation. Default = TRUE.

overwrite

Whether to overwrite an existing file. Default = FALSE, which appends a numeric index to the filename.

Value

Original ggplot object, invisibly.


adamleejohnson/R-ajtools documentation built on April 4, 2022, 7:24 a.m.