Skip to contents

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, height and dpi based on the type of output the visualisation is required for. Accepts one of c("twitter", "web", "linkedin", "facebook", "print") and overwrites user-provided values. If NULL (default) inherits ggplot2::ggsave default values.

if TRUE add Cesar logo at top right. Defaults to FALSE

...

additional arguments to that pass to ggsave

Value

exports a file with Cesar dimensions

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")  } # }