Skip to contents

Inserts shaded rectangles behind the data layer, one per level of the categorical axis variable.

Usage

fmt_bg(
  plot,
  palette = NULL,
  palcolor = NULL,
  alpha = 0.3,
  bg_axis = c("x", "y")
)

Arguments

plot

A ggplot, patchwork, or list of ggplots.

palette

Palette name passed to plotthis::palette_this.

palcolor

Manual colour vector (overrides palette).

alpha

Transparency of the background rectangles.

bg_axis

Which axis holds the categorical variable: "x" or "y".

Value

Same type as input.

Examples

library(ggplot2)
p <- ggplot(iris, aes(Species, Sepal.Length)) + geom_boxplot()
fmt_bg(p, alpha = 0.2)