fp_set_favors: Set favors indicators around the x-axis

View source: R/fp_decorate_graph.R

fp_set_favorsR Documentation

Set favors indicators around the x-axis

Description

Adds left/right "Favours ..." indicators with optional arrows either inside the graph (just above the x-axis) or outside (below the x-axis labels).

Usage

fp_set_favors(
  x,
  low = "Group 1",
  high = "Group 2",
  arrows = TRUE,
  position = c("outside", "inside"),
  txt_gp = NULL,
  arrow_gp = NULL,
  label_x_nudge = NULL,
  label_y_nudge = NULL
)

Arguments

x

The forestplot object

low

Label for the lower (left) side. Can be a character string or decorated with ⁠fp_txt_*⁠ functions. The text is used as provided.

high

Label for the upper (right) side. Can be a character string or decorated with ⁠fp_txt_*⁠ functions. The text is used as provided.

arrows

Should arrows pointing away from the center be drawn?

position

Where to draw the indicators: "outside" (default, below axis) or "inside" (inside graph, just above axis).

txt_gp

Optional grid::gpar() overrides for both favors labels.

arrow_gp

Optional grid::gpar() for arrows.

label_x_nudge

Horizontal nudge for favors labels from the arrow heads. Accepts grid::unit() or numeric (interpreted as mm). If NULL it scales automatically with the effective text cex.

label_y_nudge

Vertical nudge for favors labels. Accepts grid::unit() or numeric (interpreted as mm). If NULL it scales automatically with the effective text cex.

Value

The forestplot object with favors indicators

See Also

Other graph modifiers: fp_add_lines(), fp_decorate_graph(), fp_insert_row(), fp_set_style(), fp_set_zebra_style()

Other forestplot functions: forestplot(), fpColors(), fpDrawNormalCI(), fpLegend(), fpShapesGp(), fp_add_lines(), fp_decorate_graph(), fp_insert_row(), fp_set_style(), fp_set_zebra_style()

Examples

data(dfHRQoL)

sweden <- dfHRQoL[dfHRQoL$group == "Sweden", ]
sweden$est <- sprintf("%.2f", sweden$mean)

sweden |>
    forestplot(
        labeltext = c(labeltext, est),
        mean = mean,
        lower = lower,
        upper = upper,
        clip = c(-.1, Inf),
        xlab = "EQ-5D index"
    ) |>
    fp_set_favors(
        low = "worse",
        high = "better",
        txt_gp = gpar(cex = 0.8)
    ) |>
    fp_set_style(
        box = "royalblue",
        line = "darkblue",
        summary = "royalblue"
    )

forestplot documentation built on March 4, 2026, 9:06 a.m.