Learn R Programming

forestplot (version 3.1.3)

fp_set_style: Set the style of the graph

Description

Sets the output style associated with the foresplot

Usage

fp_set_style(
  x,
  default = NULL,
  box = NULL,
  lines = NULL,
  vertices = NULL,
  summary = NULL,
  zero = NULL,
  axes = NULL,
  hrz_lines = NULL,
  grid = NULL,
  txt_gp = NULL,
  align = NULL
)

Value

The foresplot object with the styles

Arguments

x

The forestplot object

default

A fallback grid::gpar for all unspecified attributes. If set to NULL then it defaults to legacy parameters, including the col, lwd.xaxis, lwd.ci and lty.ci parameter of fpColors.

box

The graphical parameters (gpar, character) of the box, circle or point indicating the point estimate, i.e. the middle of the confidence interval (may be a list of gpars). If provided a string a gpar will be generated with col, and fill for those arguments.

lines

The graphical parameters (gpar, character) of the confidence lines (may be a list of gpars). If provided a string a gpar will be generated with col as the only arguments.

vertices

The graphical parameters (gpar, character) of the vertices (may be a list of gpars). If ci.vertices is set to TRUE in forestplot vertices inherits from lines all its parameters but lty that is set to "solid" by default.

summary

The graphical parameters (gpar, character) of the summary (may be a list of gpars). If provided a string a gpar will be generated with col, and fill for those arguments.

zero

The graphical parameters (gpar) of the zero line (may not be a list of gpars). If provided a string a gpar will be generated with col as the only arguments.

axes

The graphical parameters (gpar) of the x-axis at the bottom (may not be a list of gpars).

hrz_lines

The graphical parameters (gpar) of the horizontal lines (may not be a list of gpars). If provided a string a gpar will be generated with col as the only arguments.

grid

The graphical parameters (gpar) of the grid (vertical lines) (may be a list of gpars). If provided a string a gpar will be generated with col as the only arguments.

txt_gp

Set the fonts etc for all text elements. See fpTxtGp() for details

align

Vector giving alignment (l,r,c) for the table columns

See Also

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

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

Examples

Run this code
base_data <- tibble::tibble(mean  = c(0.578, 0.165, 0.246, 0.700, 0.348, 0.139, 1.017),
                            lower = c(0.372, 0.018, 0.072, 0.333, 0.083, 0.016, 0.365),
                            upper = c(0.898, 1.517, 0.833, 1.474, 1.455, 1.209, 2.831),
                            study = c("Auckland", "Block", "Doran", "Gamsu",
                                      "Morrison", "Papageorgiou", "Tauesch"),
                            deaths_steroid = c("36", "1", "4", "14", "3", "1", "8"),
                            deaths_placebo = c("60", "5", "11", "20", "7", "7", "10"),
                            OR = c("0.58", "0.16", "0.25", "0.70", "0.35", "0.14", "1.02"))

base_data |>
  forestplot(labeltext = c(study, deaths_steroid, deaths_placebo, OR),
             clip = c(0.1, 2.5),
             xlog = TRUE) |>
  fp_add_header(study = c("", "Study"),
                deaths_steroid = c("Deaths", "(steroid)"),
                deaths_placebo = c("Deaths", "(placebo)"),
                OR = c("", "OR")) |>
  fp_set_style(box = "royalblue",
               line = "darkblue",
               summary = gpar(fill = "royalblue", clr = "black"),
               txt_gp = fpTxtGp(label = gpar(fontfamily = "mono")))

Run the code above in your browser using DataLab