NoteAuto-Scaling by Default

webforest automatically calculates appropriate axis ranges and tick positions based on your data. Only override when you need specific control.

Axis Control

Axis Range

By default, the axis range is auto-calculated to fit your data. Override with axis_range:

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  axis_range = c(0.3, 2.0),
  theme = web_theme_modern()
)

Custom Tick Values

Specify exact tick positions with axis_ticks:

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  axis_range = c(0.3, 2.0),
  axis_ticks = c(0.5, 0.7, 1.0, 1.5, 2.0),
  theme = web_theme_modern()
)

Gridlines

Add vertical gridlines at tick positions:

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  axis_gridlines = TRUE,
  theme = web_theme_modern()
)

Customize gridline style via theme:

Code
custom_theme <- web_theme_modern() |>
  set_axis(gridlines = TRUE, gridline_style = "dotted")

forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  theme = custom_theme
)

Gridline styles: "solid", "dashed", "dotted".

Axis Label

Add a label below the axis:

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  axis_label = "Hazard Ratio (95% CI)",
  theme = web_theme_modern()
)

Scale Types

Linear Scale

Default for differences (e.g., mean difference, risk difference):

Code
diff_data <- data.frame(
  study = c("Study A", "Study B", "Study C"),
  md = c(-0.5, 0.2, -0.3),
  lower = c(-0.9, -0.2, -0.7),
  upper = c(-0.1, 0.6, 0.1)
)

forest_plot(diff_data,
  point = "md", lower = "lower", upper = "upper",
  label = "study", null_value = 0,
  axis_label = "Mean Difference (95% CI)",
  theme = web_theme_modern()
)

Log Scale

Use for ratios (odds ratio, hazard ratio, risk ratio):

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  axis_label = "Hazard Ratio (95% CI)",
  theme = web_theme_modern()
)

Reference Lines

Null Value Line

The null_value parameter draws a dashed vertical reference line:

  • Use null_value = 1 for ratios (OR, HR, RR)
  • Use null_value = 0 for differences (MD, RD)

Custom Reference Lines

Add additional reference lines with forest_refline():

Code
spec <- web_spec(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  annotations = list(
    forest_refline(0.8, label = "Threshold", style = "dashed", color = "#e11d48")
  )
)

forest_plot(spec, axis_label = "Hazard Ratio (95% CI)")

Reference line options:

forest_refline(
  value,             # X-axis position
  label = NULL,      # Optional label text
  style = "dashed",  # "solid", "dashed", "dotted"
  color = "#94a3b8"  # Line color
)

Labels

Title and Subtitle

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  title = "Treatment Effect on Primary Outcome",
  subtitle = "Randomized controlled trials, 2020-2024",
  theme = web_theme_modern()
)

Caption and Footnote

Code
forest_plot(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  title = "Treatment Effect",
  caption = "HR < 1 favors treatment",
  footnote = "Random effects meta-analysis",
  theme = web_theme_modern()
)

All Labels Together

Code
spec <- web_spec(meta_data,
  point = "hr", lower = "lower", upper = "upper",
  label = "study", null_value = 1, scale = "log",
  title = "Treatment Effect on Primary Outcome",
  subtitle = "Randomized controlled trials, 2020-2024",
  caption = "HR < 1 favors treatment",
  footnote = "Random effects meta-analysis with DerSimonian-Laird estimator"
)

forest_plot(spec, axis_label = "Hazard Ratio (95% CI)")

Summary

Parameter Description Example
axis_range Min/max axis values c(0.3, 2.0)
axis_ticks Custom tick positions c(0.5, 1, 2)
axis_gridlines Show vertical gridlines TRUE
axis_label X-axis label "Odds Ratio"
scale Linear or log scale "log"
null_value Reference line position 1
title Plot title "My Analysis"
subtitle Secondary title "2020-2024"
caption Bottom caption "HR < 1 favors..."
footnote Footnote text "Random effects"