View source: R/DefineColorMap.R
DefineColorMap | R Documentation |
DefineColorMap provides a general method to define piecewise translations of numeric values into colors. It can be used in combination with MakeColors and ColorLegend to produce plots with precise and easy to interpret color informations.
DefineColorMap(
thresholds = NULL,
colors = NULL,
range = NULL,
number = NULL,
below = NA,
above = NA,
na = NA,
levels = 256,
centered = FALSE,
extra = NULL,
name = ""
)
thresholds |
numeric vector defining the boundaries for each range of values to be
mapped into a specific color interval. When unspecified, thresholds are
automatically set according to the |
colors |
color vector providing the colors representing each threshold value (default = rainbow). |
range |
range of the numeric values to be represented
(default = |
number |
the number of color intervals, used only if thresholds and colors
are unspecified (default = |
below |
color used for all values below the minimum threshold
(defaut = |
above |
color used for all values above the maximum threshold
(defaut = |
na |
color used for missing ( |
levels |
integer vector controlling the number of color levels generated in each
color interval (default = |
centered |
logical value. |
extra |
numeric value between 1.0 and above, defining the fraction of the colorscale used to represent below and above colors with ColorLegend. The default values are either 1.0, 1.15 or 1.2, depending how below and above colors are specified. |
name |
recall a predefined set of color mapping parameters. |
DefineColorMap
returns a ColorParameters object which consists in
a list
containing the following elements:
thresholds
, colors
, range
, number
,
below
, above
, na
, levels
, centered
,
extra
, name
.
UpdateDefinition, MakeColors, ColorLegend, DefineGroupStyles
# Radial color gradient with two normally distributed random variables
x <- rnorm(2000)
y <- rnorm(2000)
z <- 2 * sqrt(x^2 + y^2)
col.par <- DefineColorMap(seq(0, 5, 1))
clrs <- MakeColors(z, parameters = col.par)
plot(x, y, xlim = c(-3, 3), ylim = c(-3, 3), pch = 20, col = clrs)
ColorLegend("topright", parameters = col.par)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.