uses ggsave to save a ggplot object to file and then opens a new device and displays it.
Plot to save, defaults to last plot displayed.
File name to create on disk.
Arguments passed on to ggplot2::ggsave
deviceDevice 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.
pathPath of the directory to save plot to: path and filename
are combined to create the fully qualified file name. Defaults to the
working directory.
scaleMultiplicative scaling factor.
width,heightPlot size in units expressed by the units argument.
If not supplied, uses the size of the current graphics device.
unitsOne of the following units in which the width and height
arguments are expressed: "in", "cm", "mm" or "px".
dpiPlot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types.
limitsizeWhen TRUE (the default), ggsave() will not
save images larger than 50x50 inches, to prevent the common error of
specifying dimensions in pixels.
bgBackground colour. If NULL, uses the plot.background fill value
from the plot theme.
create.dirWhether 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.
if (FALSE) {
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
ggpreview()
}