save_plot: Save a ggplot plot

Description Usage Arguments Value See Also

View source: R/reproducible_graphics.r

Description

Save a ggplot plot

Usage

1
2
3
4
5
6
7
8
save_plot(
  plot,
  filename,
  scale_mult = 1,
  bg = "transparent",
  device = NULL,
  reproducible = NULL
)

Arguments

plot

The plot created by ggplot2::ggplot()

filename

The filename(s) to save (save type depends on extension)

scale_mult

A scale multiplier on the size. Defaults to 1; bigger numbers use a larger canvas. (If length 2, multiply width and height)

bg

The background color, passed to the output device. The default is "transparent". If set to "transparent", the plot will be modified to make the panel.background, plot.background, legend.background, and legend.box.background transparent as well. Set it to "white" to retain the normal ggplot behavior.

device

The device to use. Default depends on filename extension. Uses cairo_pdf devices when available. Use "tex" or "tikz" to save with tikzDevice::tikz().

reproducible

Logical. Should we try to make the plot reproducible by resetting the embedded timestamp? Defaults to false unless the SOURCE_DATE_EPOCH environment variable or SOURCE_DATE_EPOCH R option is set. If reproducible is TRUE and SOURCE_DATE_EPOCH isn't set, the timestamp we reset to is 1970-01-01 00:00:00 UTC. Other sources of non-reproducibility aren't handled. Requires system sed command.

Value

The plot (invisibly)

See Also

ggplot2::ggsave() https://reproducible-builds.org/docs/source-date-epoch/

Note that creating reproducible outputs currently depends on the system command sed, which isn't installed by default on Windows. This implementation of reproducible outputs is incompatible with multi-file outputs, like tikz.


karldw/kdw.junk documentation built on Sept. 8, 2021, 9:30 p.m.