This wraps ggsave and opens the folder where the graph was saved in a Shell. From there, it can easily be dragged and dropped into the application where you want to use it. It also changes the default units from in to cm, and defaults to saving temporary png files.

ggsave_show(filename = NULL, ..., device = NULL, units = "cm")

Source

https://stackoverflow.com/a/12135823/10581449

Arguments

filename

File name with path. If not provided, only a temporary file is saved

...

Arguments passed on to ggplot2::ggsave

plot

Plot to save, defaults to last plot displayed.

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.

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).

units

Unit for width and height, if provided. Defaults to "cm", can also be "in" or "mm"

Examples

if (FALSE) {
ggplot(mtcars, aes(mpg)) + geom_histogram()
ggsave_show(here::here("mtcars.pdf"))
}