Save a ggplot (or other grid object) with ggsaveR enhancements.
ggsave.Rd
ggsave()
is a convenient function for saving a plot. It defaults to
saving the last plot that you displayed, and it uses the file extension to
figure out which graphics device to use. ggsaveR
extends this behavior
with several new features controlled by R options, such as saving to
multiple formats at once, embedding reproducibility data in PNGs, and
advanced file overwrite controls.
Usage
ggsave(filename, plot = last_plot(), device = NULL, ..., guard = FALSE)
Arguments
- filename
File name to create on disk.
- plot
Plot to save, defaults to the last plot displayed.
- device
Device to use. See
ggsave
for details. When using theggsaveR.formats
option, this argument is ignored.- guard
A logical flag. If
TRUE
,ggsaveR
's enhancements are bypassed, and the call is forwarded directly toggplot2::ggsave()
.- ...
Other arguments passed on to the graphics device function, such as
width
,height
,units
, ordpi
.
ggsaveR Enhancements
Multiple Formats: Set the
ggsaveR.formats
option to a list of output configurations to save to multiple files at once (e.g., PNG, PDF, and SVG).Data Embedding: Set
ggsaveR.embed_data = TRUE
to embed the plot object, data, session info, and the generating call into the PNG file. This data can be retrieved withread_ggsaveR_data()
.Overwrite Control: Set the
ggsaveR.overwrite_action
option to"overwrite"
(default),"stop"
(to error if the file exists), or"unique"
(to save to a new file likeplot-1.png
).Creator Metadata: Set the
ggsaveR.creator
option to add an author/creator field to the file's metadata.