Wrapper around ggplot2::ggsave with Cesar standards
Usage
cesar_save(
filename,
plot = last_plot(),
path = NULL,
preset = NULL,
logo = FALSE,
scale = 1,
width = NA,
height = NA,
units = c("in", "cm", "mm", "px"),
dpi = 300,
...
)Arguments
- filename
File name to create on disk, png unless otherwise specified
- 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.
- preset
Passes pre-determined values to the arguments
scale,width,heightanddpibased on the type of output the visualisation is required for. Accepts one ofc("twitter", "web", "linkedin", "facebook", "print")and overwrites user-provided values. IfNULL(default) inheritsggplot2::ggsavedefault values.- logo
if
TRUEadd Cesar logo at top right. Defaults toFALSE- ...
additional arguments to that pass to ggsave
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
ggplot(iris, aes(Sepal.Length, y = Sepal.Width, colour = Species)) +
geom_point() + theme_cesar()
#default save
cesar_save("out/sepal.png")
#defaults to png if not specified (.pdf, .svg, .jpeg)
cesar_save("out/sepal")
#change the preset
cesar_save("out/sepal.jpeg", preset = "twitter") } # }
