ggplot_list_saver: Create and save sequential (or branching) ggplot figures

View source: R/ggplot_lister.R

ggplot_list_saverR Documentation

Create and save sequential (or branching) ggplot figures

Description

Create and save sequential (or branching) ggplot figures

Usage

ggplot_list_saver(
  gglist,
  base.name,
  filetype = ".jpg",
  save.path = ".",
  suffix = "-V",
  niceties = NULL,
  ...
)

Arguments

gglist

A list of ggplot layers, augmented with whole numbers to specify commands. First item in the list must be a ggplot() call. 0 specifies printing, negative integers specify removing the previous n layers before continuing. Each item MUST be either a ggplot() call, ggplot layer, 0, or negative whole number.

base.name

Name for plots (numbers will be added) without filetype.

filetype

suffix for file type, including period. Default is ".jpg"

save.path

Path to save files to. Default is current working directory.

suffix

Optional suffix to separate base name from plot numbers. Default is "-V". Set to "" to ignore.

niceties

A single ggplot layer or a list of ggplot layers that should be applied to all plots, and are applied last. Common use case would be a list of axis labels, plot title, and theme. Defaults to NULL; in this case, no layers added. Note that this formulation is merely for convenience – these layers can also be specified in gglist, but would generally need to be added before the first 0 entry.

...

Additional arguments passed to ggsave. Likely choices: width, height, units, dpi. See ?ggsave for details.

Value

Logical

Examples


library(tidyverse)
dat = data.frame(y = runif(30), x = runif(30))
# ggplot_list_saver(gglist = list(ggplot(data = dat, aes(x = x, y = y)),
#   geom_point(), 0,
#   geom_path(),0, -1, geom_smooth(method = 'lm')),
#   niceties = list(xlab("turtle"), ylab("cow"), theme_bw()),
#   base.name = "testfig",
#   save.path = "."
# )

cbedwards/cedwards documentation built on Feb. 24, 2023, 6:53 p.m.