gg_concat | R Documentation |
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
gg_concat(e1, e2)
e1 |
Left-hand side of addition operation |
e2 |
Right-hand side of addition operation |
A list of gg objects
custom_geom <- function(fill = "red") aes(fill = !!fill) + geom_boxplot() + geom_jitter()
ggplot() + custom_geom()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.