AddColorKey | R Documentation |
Add a color key to a plot.
AddColorKey( breaks, is.categorical = FALSE, col = NULL, at = NULL, labels = TRUE, scipen = getOption("scipen", 0), explanation = NULL, padx = 0.2, log = FALSE, mai = NULL )
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 |
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 |
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 |
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 |
Invisible NULL
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
PlotCrossSection
, PlotMap
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.