Learn R Programming

inlmisc (version 0.5.5)

AddColorKey: Add Color Key to Plot

Description

Add a color key to a plot.

Usage

AddColorKey(
  breaks,
  is.categorical = FALSE,
  col = NULL,
  at = NULL,
  labels = TRUE,
  scipen = getOption("scipen", 0),
  explanation = NULL,
  padx = 0.2,
  log = FALSE,
  mai = NULL
)

Arguments

breaks

'numeric' vector. Finite breakpoints for the colors: must have one more breakpoint than color and be in increasing order.

is.categorical

'logical' flag. If true, color-key values represent categorical data; otherwise, these data values are assumed continuous.

col

'character' vector. Colors to be used in the plot. This argument requires breaks specification for continuous data. For continuous data there should be one less color than breaks; whereas, categorical data require a color for each category.

at

'numeric' vector. Points at which tick-marks and labels are to be drawn, only applicable for continuous data. The tick marks will be located at the color breaks if the length of at is greater than or equal to one minus the length of breaks. Tick-mark labels are omitted where they would abut or overlap previously drawn labels (labels are drawn left to right).

labels

'logical' flag, 'character' vector, 'expression' vector, 'numeric' vector, or 'factor' vector. Can either be a flag specifying whether (numerical) annotations are to be made at the tick marks, or a vector of labels to be placed at the tick points.

scipen

'integer' count. Penalty to be applied when deciding to format numeric values in scientific or fixed notation. Positive values bias towards fixed and negative towards scientific notation: fixed notation will be preferred unless it is more than scipen digits wider. Specify NULL to format all numbers, with the exception of zero, in scientific notation.

explanation

'character' string. Label that describes the data values.

padx

'numeric' number. Inner padding for the left and right margins specified in inches.

log

'logical' flag. Whether the axis is to be logarithmic.

mai

'numeric' vector of length 4. Margin size in inches and of the form c(bottom, left, top, right).

Value

Invisible NULL

See Also

PlotCrossSection, PlotMap

Examples

Run this code
# NOT RUN {
op <- par(mfrow = c(7, 1), omi = c(1, 1, 1, 1),
          mar = c(2, 3, 2, 3))
AddColorKey(breaks = 0:10,
            explanation = "Example description of data variable.")
AddColorKey(breaks = 0:1000, at = pretty(0:1000))
AddColorKey(breaks = c(0, 1, 2, 4, 8, 16))
breaks <- c(pi * 10^(-5:5))
AddColorKey(breaks = breaks, log = TRUE)
AddColorKey(breaks = breaks,
            at = breaks[as.logical(seq_along(breaks) %% 2)],
            scipen = NULL, log = TRUE)
AddColorKey(is.categorical = TRUE, labels = LETTERS[1:5])
AddColorKey(is.categorical = TRUE,
            col = GetColors(5, scheme = "bright"))
par(op)

# }

Run the code above in your browser using DataLab