scale_x_foresttable() constructs a continuous x scale designed for use with
geom_foresttable(). It places table column headers on the top axis tick
labels, sets appropriate breaks and limits based on the requested columns,
and ensures consistent spacing so that table panels align cleanly with forest
plots when composed using patchwork.
scale_x_foresttable(
cols,
col_labels = NULL,
col_gap = 1,
position = "top",
expand = ggplot2::expansion(mult = c(0, 0)),
limits = NULL,
...
)A ggplot2 scale object suitable for addition to a plot.
Character vector of column names corresponding to the table columns. Determines the number, order, and spacing of x-axis breaks.
Optional character vector giving display labels for each
column. If unnamed, must be the same length as cols and is assumed to be
in the same order. If named, names are matched to cols.
Numeric. Spacing between adjacent columns on the x axis.
Character. Position of the x axis; defaults to "top".
Expansion applied to the x scale. Defaults to no expansion
(expansion(mult = c(0, 0))).
Optional numeric vector of length 2 giving explicit x-axis
limits. If NULL, limits are computed automatically to bracket all columns.
Additional arguments passed to ggplot2::scale_x_continuous().
The scale uses numeric x positions internally (one per column), which allows precise control over column spacing and alignment.
This scale is typically paired with geom_foresttable() and a void theme
(theme_void()) to create a table-like panel whose headers are rendered as
axis labels. Because headers are true axis labels, ggplot2 can align the table
panel perfectly with a forest plot panel when combining plots.
geom_foresttable(), gg_forest()