usrBox function

Draw colored box indicating R plot space

Draw colored box indicating R plot space

Draw colored box indicating the active R plot space

usrBox( fill = "#FFFF9966", label = NULL, parUsr = graphics::par("usr"), debug = FALSE, ... )

Arguments

  • fill: character R color used to fill the background of the plot
  • label: character text optionally used to label the center of the plot space, default NULL
  • parUsr: numeric vector length 4, indicating the R plot space, consistent with graphics::par("usr"). It can thus be used to define a different area, though using the rect function directly seems more appropriate.
  • debug: logical whether to print the parUsr value being used.
  • ...: additional arguments are ignored.

Returns

no output, this function is called for the byproduct of adding a box in the usr plot space of an R graphics device.

Details

This function simply draws a box indicating the active plot space, and by default it shades the box light yellow with transparency. It can be useful to indicate the active plot area while allowing pre-drawn plot elements to be shown, or can be useful precursor to provide a colored background for the plot.

The plot space is defined using graphics::par("usr") and therefore requires an active R device is already opened.

Examples

# usrBox() requires that a plot device is already open nullPlot(doBoxes=FALSE); usrBox();

See Also

Other jam plot functions: adjustAxisLabelMargins(), coordPresets(), decideMfrow(), drawLabels(), getPlotAspect(), groupedAxis(), imageByColors(), imageDefault(), minorLogTicksAxis(), nullPlot(), plotPolygonDensity(), plotRidges(), plotSmoothScatter(), shadowText(), shadowText_options(), showColors(), sqrtAxis()

  • Maintainer: James M. Ward
  • License: MIT + file LICENSE
  • Last published: 2025-03-23