layout-operator {ggalign} | R Documentation |
Plot arithmetic
Description
Plot arithmetic
Usage
## S4 method for signature 'Layout,ANY'
e1 & e2
## S4 method for signature 'Layout,ANY'
e1 - e2
Arguments
e1 |
A |
e2 |
An object to be added to the plot. |
Details
In order to reduce code repetition ggalign
provides two operators for
adding ggplot elements (geoms, themes, facets, etc.) to multiple/all plots in
layout_heatmap()
or layout_stack()
object.
Like patchwork
, &
add the element to all plots in the plot. If the
element is a theme, this will also modify the layout theme.
Unlike patchwork
, the -
operator adds ggplot2 elements (geoms, themes,
facets, etc.) rather than a ggplot plot. The key difference between &
and
-
is in how they behave in layout_heatmap()
. The -
operator only
applies the element to the current active context in layout_heatmap()
.
Using -
might seem unintuitive if you think of the operator as "subtract",
the underlying reason is that -
is the only operator in the same precedence
group as +
.
Value
A modified Layout
object.
Examples
mat <- matrix(rnorm(81), nrow = 9)
ggheatmap(mat) +
hmanno("top") +
align_dendro() &
theme(panel.border = element_rect(
colour = "red", fill = NA, linewidth = unit(2, "mm")
))
ggheatmap(mat) +
hmanno("top") +
align_dendro() -
theme(panel.border = element_rect(
colour = "red", fill = NA, linewidth = unit(2, "mm")
))