Skip to contents

Wrapper around ragg::agg_png() that saves the output from a plotting expression to a special folder and opens it using the system's default app for the graphic type.

Usage

raggsave_auto(plot_expr = NULL, ..., load_as_magick = FALSE)

Arguments

plot_expr

An expression that plots a figure to a device as a side effect, to be captured by ragg::agg_png().

...

Passed to ragg::agg_png(), overriding filename. Uses the same width and height as the RStudio viewer pane size by default, like ggplot2::ggsave().

load_as_magick

Whether to show information about the saved plot and invisibly return an ImageMagick object of the plot for post-processing. Defaults to FALSE.

Value

A magick object or path to the saved plot.

Note

Creates a folder /.raggsave_auto in the working directory where figures are saved with zero-padding to 3 digits (e.g., raggsave_auto-001.png). Appends .raggsave_auto to a .gitignore file if it exists.

Global params can be set through options(), with the argument name followed by pgl.raggsave_auto. such as options(pgl.raggsave_auto.width = 7).