| color_ramp_continuous | R Documentation |
Linearly maps a numeric vector onto a color ramp, clamping values outside the given range to the range's endpoints.
color_ramp_continuous(
values,
clim = range(values, na.rm = TRUE),
cmap = grDevices::hcl.colors(11),
...
)
values |
numeric vector of values to map to colors |
clim |
length-two numeric vector giving the value range to map from;
values outside |
cmap |
the color ramp to map onto: either a vector of colors (passed
to |
... |
passed to |
A character vector of '#RRGGBB' (or '#RRGGBBAA')
color strings, the same length as values.
x <- rnorm(100)
col <- color_ramp_continuous(x)
plot(x, col = col, pch = 16)
# Change color palettes with vector of colors
col <- color_ramp_continuous(
x, cmap = c("lightgreen", "white", "pink"))
plot(x, col = col, pch = 16)
# Using colorRamp
col <- color_ramp_continuous(
x, cmap = colorRamp(c("black", "orangered", "orange")))
plot(x, col = col, pch = 16)
# Using color ramp palette `function(n) { ... }`
col <- color_ramp_continuous(
x, cmap = hcl.colors, palette = "Blue-Red 3")
plot(x, col = col, pch = 16)
# Set range
col <- color_ramp_continuous(
x, clim = c(0, 1),
cmap = c("black", "orangered", "orange"))
plot(x, col = col, pch = 16)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.