Learn R Programming

inlmisc (version 0.3.2)

AddColorKey: Add Color Key to Plot

Description

This function can be used to add a color key to a plot.

Usage

AddColorKey(mai, is.categorical, breaks, col, at = NULL, labels = TRUE,
  scientific = FALSE, explanation = NULL, padx = 0.2)

Arguments

mai

'numeric'. Vector of the form c(bottom, left, top, right) which gives the margin size specified in inches (optional).

is.categorical

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

breaks

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

col

'character'. Vector of 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'. The 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.

labels

'logical' or 'character'. Can either be a logical value specifying whether (numerical) annotations are to be made at the tickmarks, or a character or expression vector of labels to be placed at the tickpoints.

scientific

'logical'. Indicates if axes labels should be formatted for scientific notation, see ToScientific for details.

explanation

'character'. Label that describes the data values.

padx

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

Value

Used for the side-effect of a color key drawn on the current graphics device.

See Also

PlotCrossSection, PlotMap

Examples

Run this code
# NOT RUN {
dev.new(width = 7, height = 2)

AddColorKey(is.categorical = FALSE, breaks = 0:10, scientific = TRUE,
            explanation = "Example description for data variables in meters.")
AddColorKey(is.categorical = FALSE, breaks = 0:10, at = pretty(0:10))
AddColorKey(is.categorical = FALSE, breaks = seq(0.5, 10.5, by = 1), at = 1:10)

AddColorKey(is.categorical = TRUE, labels = LETTERS[1:5])
AddColorKey(is.categorical = TRUE, col = terrain.colors(5))

dev.off()

# }

Run the code above in your browser using DataLab