Skip to contents

Creates a forestploter theme with parameters that control overall plot sizing and appearance. This is the primary way to control how large the forest plot renders.

Usage

create_forest_theme(
  base_size = 10,
  scale = 1,
  row_padding = NULL,
  ci_pch = 15,
  ci_lwd = NULL,
  ci_Theight = NULL,
  ci_col = "black",
  header_fontsize = NULL,
  body_fontsize = NULL,
  footnote_fontsize = NULL,
  footnote_col = "darkcyan",
  title_fontsize = NULL,
  cv_fontsize = NULL,
  cv_col = "gray30",
  refline_lwd = NULL,
  refline_lty = "dashed",
  refline_col = "gray30",
  vertline_lwd = NULL,
  vertline_lty = "dashed",
  vertline_col = "gray20",
  arrow_type = "closed",
  arrow_col = "black",
  summary_fill = "black",
  summary_col = "black"
)

Arguments

base_size

Numeric. Base font size in points. This is the primary scaling parameter - increasing it will proportionally scale all fonts, row padding, and line widths. Default: 10.

scale

Numeric. Additional scaling multiplier applied on top of base_size. Use for quick overall scaling. Default: 1.0.

row_padding

Numeric vector of length 2. Padding around row content in mm as c(vertical, horizontal). If NULL, auto-calculated from base_size. Default: NULL.

ci_pch

Integer. Point character for CI. 15=square, 16=circle, 18=diamond. Default: 15.

ci_lwd

Numeric. Line width for CI lines. If NULL, auto-calculated from base_size. Default: NULL.

ci_Theight

Numeric. Height of T-bar ends on CI. If NULL, auto-calculated from base_size. Default: NULL.

ci_col

Character. Color for CI lines and points. Default: "black".

header_fontsize

Numeric. Font size for column headers. If NULL, auto-calculated as base_size * scale + 1. Default: NULL.

body_fontsize

Numeric. Font size for body text. If NULL, auto-calculated as base_size * scale. Default: NULL.

footnote_fontsize

Numeric. Font size for footnotes. If NULL, auto-calculated as base_size * scale - 1. Default: NULL.

footnote_col

Character. Color for footnote text. Default: "darkcyan".

title_fontsize

Numeric. Font size for title. If NULL, auto-calculated as base_size * scale + 4. Default: NULL.

cv_fontsize

Numeric. Font size for CV annotation text. If NULL, auto-calculated as base_size * scale. Default: NULL.

cv_col

Character. Color for CV annotation text. Default: "gray30".

refline_lwd

Numeric. Reference line width. If NULL, auto-calculated. Default: NULL.

refline_lty

Character. Reference line type. Default: "dashed".

refline_col

Character. Reference line color. Default: "gray30".

vertline_lwd

Numeric. Vertical line width. If NULL, auto-calculated. Default: NULL.

vertline_lty

Character. Vertical line type. Default: "dashed".

vertline_col

Character. Vertical line color. Default: "gray20".

arrow_type

Character. Arrow type: "open" or "closed". Default: "closed".

arrow_col

Character. Arrow color. Default: "black".

summary_fill

Character. Fill color for summary diamonds. Default: "black".

summary_col

Character. Border color for summary diamonds. Default: "black".

Value

A list of class "fs_forest_theme" containing all theme parameters.

Details

The base_size parameter is the primary way to control plot size. When you change base_size, the following are automatically scaled:

  • All font sizes (body, header, footnote, CV, title)

  • Row padding (vertical and horizontal)

  • CI line width and T-bar height

  • Reference and vertical line widths

The scaling formula uses base_size = 10 as the reference point:

  • base_size = 10: Default sizing

  • base_size = 12: 20% larger

  • base_size = 14: 40% larger

  • base_size = 16: 60% larger

You can override any individual parameter by specifying it explicitly.

The theme does NOT set row background colors - those are determined automatically by plot_subgroup_results_forestplot() based on row types (ITT, reference, posthoc, etc.).

Examples

# \donttest{
# Simple: just increase base_size for larger plot
large_theme <- create_forest_theme(base_size = 14)
print(large_theme)
#> $base_size
#> [1] 14
#> 
#> $scale
#> [1] 1
#> 
#> $size_factor
#> [1] 1.4
#> 
#> $row_padding
#> [1] 5.6 5.6
#> 
#> $body_fontsize
#> [1] 14
#> 
#> $header_fontsize
#> [1] 15
#> 
#> $footnote_fontsize
#> [1] 13
#> 
#> $footnote_col
#> [1] "darkcyan"
#> 
#> $title_fontsize
#> [1] 18
#> 
#> $cv_fontsize
#> [1] 14
#> 
#> $cv_col
#> [1] "gray30"
#> 
#> $ci_pch
#> [1] 15
#> 
#> $ci_lwd
#> [1] 2.1
#> 
#> $ci_Theight
#> [1] 0.28
#> 
#> $ci_col
#> [1] "black"
#> 
#> $refline_lwd
#> [1] 1.4
#> 
#> $refline_lty
#> [1] "dashed"
#> 
#> $refline_col
#> [1] "gray30"
#> 
#> $vertline_lwd
#> [1] 1.4
#> 
#> $vertline_lty
#> [1] "dashed"
#> 
#> $vertline_col
#> [1] "gray20"
#> 
#> $arrow_type
#> [1] "closed"
#> 
#> $arrow_col
#> [1] "black"
#> 
#> $summary_fill
#> [1] "black"
#> 
#> $summary_col
#> [1] "black"
#> 
#> attr(,"class")
#> [1] "fs_forest_theme" "list"           

# Or use scale for quick adjustment
large_theme <- create_forest_theme(base_size = 10, scale = 1.4)

# Fine-tune specific elements
custom_theme <- create_forest_theme(
  base_size = 14,
  cv_fontsize = 12,
  ci_lwd = 2.5
)
# }