valueToColor | R Documentation |
valueToColor
takes a numerical vector and maps each value
to an R color string.
valueToColor(
x,
rng = range(x, na.rm = TRUE),
col = c("#5E4FA2", "#3288BD", "#66C2A5", "#ABDDA4", "#E6F598", "#FFFFBF", "#FEE08B",
"#FDAE61", "#F46D43", "#D53E4F", "#9E0142"),
NA.col = "lightgray",
alpha = NULL
)
x |
|
rng |
|
col |
vector with R colors defining the palette (must be a valid argument
to |
NA.col |
Single R color to use for |
alpha |
|
The values in [rng[1], rng[2]]
will be linearly mapped to the
color palette defined by col
. Any values in x
less (greater)
than rng[1]
(rng[2]
) will be assigned the same color as
rng[1]
(rng[2]
).
A character
vector of the same length of x
with
R colors in hexadecimal string-encoded RGB format.
Michael Stadler
colorRamp
and rgb
for the functions called by valueToColor
.
x <- rnorm(1000)
y <- rnorm(1000)
cols <- valueToColor(x + y)
plot(x, y, pch = 20, col = cols, main = "default")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.