fpLegend: A function for the legend used in forestplot()

View source: R/forestplot_helpers.R

fpLegendR Documentation

A function for the legend used in forestplot()

Description

This function encapsulates all the legend options that are used in the forestplot function. This is in order to limit the crowding among the arguments for the forestplot call.

Usage

fpLegend(
  pos = "top",
  gp = NULL,
  r = unit(0, "snpc"),
  padding = unit(ifelse(!is.null(gp), 3, 0), "mm"),
  title = NULL
)

Arguments

pos

The position of the legend, either at the "top" or the "right" unless positioned inside the plot. If you want the legend to be positioned inside the plot then you have to provide a list with the same x & y qualities as legend. For instance if you want the legend to be positioned at the top right corner then use pos = list("topright") - this is equivalent to pos = list(x = 1, y = 1). If you want to have a distance from the edge of the graph then add a inset to the list, e.g. pos = list("topright", "inset" = .1) - the inset should be either a unit element or a value between 0 and 1. The default is to have the boxes aligned vertical, if you want them to be in a line then you can specify the "align" option, e.g. pos = list("topright", "inset" = .1, "align" = "horizontal")

gp

The gpar options for the legend. If you want the background color to be light grey then use gp = gpar(fill = "lightgrey"). If you want a border then set the col argument: gp = gpar(fill = "lightgrey", col = "black"). You can also use the lwd and lty argument as usual, gp = gpar(lwd = 2, lty = 1), will result in a black border box of line type 1 and line width 2.

r

The box can have rounded edges, check out grid.roundrect. The r option should be a unit object. This is by default unit(0, "snpc") but you can choose any value that you want. The "snpc" unit is the preferred option.

padding

The padding for the legend box, only used if box is drawn. This is the distance from the border to the text/boxes of the legend.

title

The title of the legend if any

Value

list Returns a list with all the elements

See Also

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


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