Learn R Programming

ggalign (version 0.0.4)

layout-operator: Layout operator

Description

Layout operator

Usage

# S4 method for Layout,ANY
&(e1, e2)

# S4 method for Layout,ANY -(e1, e2)

Value

A modified Layout object.

Arguments

e1

A heatmap_layout() or stack_layout() object.

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 heatmap_layout() or stack_layout() 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 heatmap_layout(). The - operator only applies the element to the current active context in heatmap_layout(). 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 +.

Examples

Run this code
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")
    ))

Run the code above in your browser using DataLab