Skip to contents

Draw a forest-style plot from a fitted gtregression object produced by functions such as uni_reg(), multi_reg(), cox_reg(), or surv_reg(). Stratified regression outputs are displayed as one faceted quick-view plot; use forest_df() and forest_reg() for publication-style stratified forest tables.

Usage

plot_reg(
  tbl,
  title = NULL,
  caption = NULL,
  ref_line = NULL,
  order_y = NULL,
  log_x = FALSE,
  xlim = NULL,
  breaks = NULL,
  point_color = "#6B7280",
  errorbar_color = "#6B7280",
  point_size = 2.8,
  point_stroke = 0.55,
  ci_linewidth = 0.55,
  base_size = 12,
  show_ref = NULL,
  sig_color = "#0072B2",
  sig_errorbar_color = "#0072B2",
  alpha = 0.05,
  show_adjustment_note = TRUE
)

Arguments

tbl

A fitted gtregression object.

title

Optional plot title.

caption

Optional plot caption. If NULL, notes are added automatically for adjusted multi_reg() objects and displayed reference categories.

ref_line

Optional numeric value for the reference line. Defaults to 0 for linear models and 1 otherwise.

order_y

Optional character vector specifying exposure order.

log_x

Logical. If TRUE, use a log-scaled x-axis for ratio measures. The default FALSE uses a linear x-axis.

xlim

Optional numeric vector of length 2 specifying x-axis limits.

breaks

Optional numeric vector of x-axis tick breaks.

point_color

Fill color for non-significant estimate points.

errorbar_color

Color for non-significant confidence intervals.

point_size

Diameter of estimate points in millimetres.

point_stroke

Outline width of estimate points.

ci_linewidth

Line width of confidence intervals.

base_size

Base font size. The default is designed for a clear report or slide figure; increase it for a single large plot.

show_ref

Logical or NULL. The default NULL inherits the reference-row choice used to create tbl. If TRUE, reference rows are shown. If FALSE, binary exposures are shown as compact rows for the estimated non-reference category; affirmative levels such as Yes or 1 are displayed using the variable name.

sig_color

Optional fill color for significant points.

sig_errorbar_color

Optional color for significant error bars.

alpha

Significance level for linear models when p.value is available.

show_adjustment_note

Logical; if TRUE, add a default caption describing adjust_for variables when available.

Value

A ggplot2 object.