fpColors: A function for the color elements used in forestplot()

View source: R/forestplot_helpers.R

fpColorsR Documentation

A function for the color elements used in forestplot()

Description

This function encapsulates all the colors that are used in the forestplot function. As there are plenty of color options this function gathers them all in one place.

Usage

fpColors(
  all.elements,
  box = "black",
  lines = "gray",
  summary = "black",
  zero = "lightgray",
  text = "black",
  axes = "black",
  hrz_lines = "black",
  vrtcl_lines = "lightgray"
)

Arguments

all.elements

A color for all the elements. If set to NULL then it's set to the par("fg") color

box

The color of the box indicating the estimate

lines

The color of the confidence lines

summary

The color of the summary

zero

The color of the zero line

text

The color of the text

axes

The color of the x-axis at the bottom

hrz_lines

The color of the horizontal lines

vrtcl_lines

The color of the vertical lines

Details

Further customization of non-text elements can be performed with fpShapesGp passed as shapes_gp parameter to forestplot. The fpColors function is kept for backwards compatibility.

If you have several values per row in a forestplot you can set a color to a vector where the first value represents the first line/box, second the second line/box etc. The vectors are only valid for the box & lines options.

This function is a copy of the meta.colors function in the rmeta package.

Value

A list with key elements

Author(s)

Max Gordon, Thomas Lumley

See Also

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

Examples

ask <- par(ask = TRUE)

# An example of how the exponential works
test_data <- data.frame(
  coef = c(2.45, 0.43),
  low = c(1.5, 0.25),
  high = c(4, 0.75),
  boxsize = c(0.5, 0.5)
)
row_names <- cbind(
  c("Name", "Variable A", "Variable B"),
  c("HR", test_data$coef)
)
test_data <- rbind(rep(NA, 3), test_data)

forestplot(
  labeltext = row_names,
  test_data[, c("coef", "low", "high")],
  is.summary = c(TRUE, FALSE, FALSE),
  boxsize = test_data$boxsize,
  zero = 1,
  xlog = TRUE,
  col = fpColors(lines = "#990000", box = "#660000", zero = "darkblue"),
  new_page = TRUE
)

par(ask = ask)

forestplot documentation built on Oct. 11, 2024, 5:07 p.m.