gg-concat: Concatenate any ggplot components

gg_concatR Documentation

Concatenate any ggplot components

Description

Typically, addition in ggplot2 with the + operator is only permitted when the left-hand side is a ggplot object or a theme object. This function extends the ggplot2 functionality and allows the user to concatenate geom, theme, stats, labels, aes, Coord, and Scale objects into bundles using the + operator. These compositions can then be stored and used later in the construction of ggplots.

A common use-case for this is to construct custom plot templates by concatenating base geoms and settings.

The addition function is designed to capture all gg objects that are not processed by the original +.gg function. See original source

Usage

gg_concat(e1, e2)

Arguments

e1

Left-hand side of addition operation

e2

Right-hand side of addition operation

Value

A list of gg objects

Usage

custom_geom <- function(fill = "red") aes(fill = !!fill) + geom_boxplot() + geom_jitter()

ggplot() + custom_geom()


adamleejohnson/R-ajtools documentation built on April 4, 2022, 7:24 a.m.