opmi_ggsave: Save OPMI-themed ggplots

View source: R/theme.R

opmi_ggsaveR Documentation

Save OPMI-themed ggplots

Description

The default ggsave options do not work well with the showtext package, which is used to get the correct fonts. This changes the resolution settings.

Usage

opmi_ggsave(
  filename,
  plot = ggplot2::last_plot(),
  device = NULL,
  path = NULL,
  scale = 1,
  width = NA,
  height = NA,
  units = c("in", "cm", "mm", "px"),
  dpi = 96,
  limitsize = TRUE,
  bg = NULL,
  ...
)

Arguments

filename

File name to create on disk.

plot

Plot to save, defaults to last plot displayed.

device

Device to use. Can either be a device function (e.g. png), or one of "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only).

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.

scale

Multiplicative scaling factor.

width, height, units

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

dpi

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

limitsize

When TRUE (the default), ggsave() will not save images larger than 50x50 inches, to prevent the common error of specifying dimensions in pixels.

bg

Background colour. If NULL, uses the plot.background fill value from the plot theme.

...

Arguments passed to ggplot2:ggsave()

Value

Saves a plot to a file.


kmeakinmbta/opmitools documentation built on Oct. 25, 2023, 10:34 a.m.