geom_foreststripe() adds alternating horizontal background bands (“zebra
striping”) to forest plots or forest tables. The stripes are drawn using the
y-axis scale (rather than the data itself), which makes the geom robust to
missing rows, summary rows, and faceting.
geom_foreststripe(
mapping = NULL,
data = NULL,
position = "identity",
...,
n_cols,
col_gap = 1,
start = 2L,
fill = "grey92",
colour = NA,
na.rm = FALSE,
show.legend = FALSE,
inherit.aes = TRUE
)A ggplot2 layer object that can be added to a plot.
Set of aesthetic mappings created by ggplot2::aes(). Usually
left empty; the geom does not require data-driven aesthetics.
The data to be displayed in this layer. If NULL, the layer
inherits the plot data; only the y scale is used.
Position adjustment. Defaults to "identity".
Additional arguments passed to the underlying GeomForestStripe.
Integer. Number of table columns. Used to determine the horizontal extent of the stripes.
Numeric. Spacing between table columns on the x axis.
Integer. Index of the first row to stripe (counting from the top
of the plot). Defaults to 2L, so striping begins on the second row.
Fill colour for the stripes.
Border colour for the stripes. Defaults to NA (no border).
Logical. If TRUE, silently ignores missing values.
Logical. Whether this layer should be included in the legend.
Defaults to FALSE.
Logical. If FALSE, the layer does not inherit aesthetic
mappings from the parent plot.
This geom is designed to work with both the forest figure panel (estimates and
confidence intervals) and the forest table panel produced by
geom_foresttable(). Because stripes are computed from the panel scales, the
two panels remain visually aligned when composed with patchwork.
The stripes are computed from the panel’s y range rather than the data rows.
For discrete y scales, this corresponds to the integer row positions used by
ggplot2. Every other row is selected starting at start.
Horizontal extents are derived from the panel x range, allowing the stripes to span both table columns and forest-plot panels without requiring explicit xmin/xmax aesthetics.
geom_foresttable(), geom_forestpoint(), gg_forest()