Skip to contents

operations can be multiplied together to form chains of operations, which when multiplied by (applied to) layer-like objects, return modified layer-like objects.

Usage

# S4 method for operation,ANY
*(e1, e2)

# S4 method for ANY,operation
*(e1, e2)

# S4 method for adjust,adjust
*(e1, e2)

# S4 method for nop,nop
*(e1, e2)

# S4 method for operation,nop
*(e1, e2)

# S4 method for operation_sum,nop
*(e1, e2)

# S4 method for nop,operation
*(e1, e2)

# S4 method for nop,operation_sum
*(e1, e2)

# S4 method for operation
prod(x, ..., na.rm = FALSE)

# S4 method for operation,operation
*(e1, e2)

# S4 method for numeric,operation
*(e1, e2)

# S4 method for operation,numeric
*(e1, e2)

# S4 method for operation,operation_sum
*(e1, e2)

# S4 method for operation_sum,operation
*(e1, e2)

# S4 method for operation_sum,operation_sum
*(e1, e2)

Arguments

e1

an operation, layer-like, or numeric()

e2

an operation, layer-like, or numeric()

x, ...

operations

na.rm

ignored

Value

An operation.

Details

Multiplication of ggblend operations depends on the types of objects being multiplied:

Examples

library(ggplot2)

# multiplying operations by numerics repeats them...
adjust(color = "red") * 2
#> <operation>: (adjust(colour = "red") + adjust(colour = "red"))

# multiplying operations together chains (or merges) them
adjust(color = "red") * adjust(linewidth = 2)
#> <operation>: adjust(colour = "red", linewidth = 2)

# multiplication obeys the distributive law
op = (adjust(aes(y = 11 -x), color = "skyblue") + 1) * (adjust(color = "white", linewidth = 4) + 1)
op
#> <operation>: (adjust(aes(y = ~11 - x), colour = "white", linewidth = 4) + adjust(aes(y = ~11 - x), colour = "skyblue") + adjust(colour = "white", linewidth = 4) + 1)

# multiplication by a geom returns a modified version of that geom
data.frame(x = 1:10) |>
  ggplot(aes(x = x, y = x)) +
  geom_line(linewidth = 2) * op