outer_legend: Add legend in the outer margin

outer_legendR Documentation

Add legend in the outer margin

Description

Add legend in the outer margin

Usage

outer_legend(
  x = "bottom",
  y = NULL,
  doPar = TRUE,
  legend,
  bg = "white",
  box.col = "grey70",
  col,
  pt.bg = NULL,
  pch = 21,
  ncol = min(c(5, length(legend))),
  cex = 1.2,
  pt.cex = 1.4,
  ...
)

Arguments

x, y

position of the legend, using any method recognized by grDevices::xy.coords().

doPar

logical indicating whether to apply graphics::par() in order to place the legend in the outer margin. If doPar=FALSE and if no other method has been done to update the graphics::par() settings, the legend will be placed with the same mechanism used by graphics::legend().

legend

character vector, or expression, used to display each legend label.

bg

color used as the background of the legend box.

box.col

color used as the frame border color of the legend box.

col

character vector of colors used to color each entry in legend.

pt.bg

vector of colors used as the background color when pch is any value from 21 to 25. When pt.bg=NULL this value and col are adjusted so the outline is darker, via jamba::makeColorDarker(), with the fill color pt.bg using the original col value.

pch

integer or character vector of point shapes, as described in graphics::points().

ncol

integer number of columns to use for legend entries. By default ncol is the smaller of length(legend) and 5, which is intended for a legend placed at the bottom of the visualization.

cex

character expansion multiplier, used to size the legend text overall.

pt.cex

point expansion factor, used to size points when pch is not NULL.

...

additional arguments are passed to graphics::legend().

Details

This function is intended to place a legend outside the figure in the outer margin area. The motivating use case is to display a legend below multi-panel base R graphics plots, for example when using par("mfrow"=c(2,2)).

See Also

Other jam utility functions: blockArrowMargin(), find_colname(), fold_to_log2fold(), get_se_assaydata(), gradient_rect(), handle_highlightPoints(), log2fold_to_fold(), logAxis(), points2polygonHull(), update_function_params(), update_list_elements()

Examples

opar <- par(no.readonly=TRUE);
on.exit(par(opar));

par("mfrow"=c(2,2));
for (i in 1:4) {
   jamba::nullPlot(plotAreaTitle=paste("Panel", i));
}
require(jamba);
outer_legend("bottom",
   legend=c("one", "two", "three"),
   col=colorjam::rainbowJam(3));


jmw86069/jamma documentation built on July 6, 2023, 1:09 p.m.