| geom_foreststripe | R Documentation |
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
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. If |
position |
Position adjustment. Defaults to |
... |
Additional arguments passed to the underlying |
n_cols |
Integer. Number of table columns. Used to determine the horizontal extent of the stripes. |
col_gap |
Numeric. Spacing between table columns on the x axis. |
start |
Integer. Index of the first row to stripe (counting from the top
of the plot). Defaults to |
fill |
Fill colour for the stripes. |
colour |
Border colour for the stripes. Defaults to |
na.rm |
Logical. If |
show.legend |
Logical. Whether this layer should be included in the legend.
Defaults to |
inherit.aes |
Logical. If |
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.
A ggplot2 layer object that can be added to a plot.
geom_foresttable(), geom_forestpoint(), gg_forest()
# geom_foreststripe() is designed to be used as part of gg_forest().
# See ?gg_forest for a complete runnable example.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.