ggsave_show: Save ggplot-graph and show in folder

View source: R/project_management.R

ggsave_showR Documentation

Save ggplot-graph and show in folder

Description

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.

Usage

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

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

Plot size in units expressed by the units argument. If not supplied, uses the size of the 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.

create.dir

Whether to create new directories if a non-existing directory is specified in the filename or path (TRUE) or return an error (FALSE, default). If FALSE and run in an interactive session, a prompt will appear asking to create a new directory when necessary.

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). If NULL (default), the device is guessed based on the filename extension.

units

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

Source

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

Examples

## Not run: 
ggplot(mtcars, aes(mpg)) + geom_histogram()
ggsave_show(here::here("mtcars.pdf"))

## End(Not run)

LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.