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 = tempfile("0_plot", fileext = ".png"),
  ...,
  device = "png",
  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

Plot size in units ("in", "cm", or "mm"). If not supplied, uses the size of current graphics device.

height

Plot size in units ("in", "cm", or "mm"). 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.

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"

Source

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

Examples

## Not run: 
ggsave_show(here::here("mtcars.pdf"))

## End(Not run)

LukasWallrich/rNuggets documentation built on Aug. 26, 2022, 11:03 a.m.