colmap | R Documentation |
Creates a color gradient function that maps numerical values to colors on a gradient. Multiple stops in the gradient can be defined as different input colors and be assigned to numerical values. For example, a gradient could start at '0' with the color blue, transition towards white as it approaches '1' and further transition to red as it approaches '2'. Values outside of the defined range would be mapped to the nearest extreme color; e.g. in the previous example, '3.1' would still map to red.
colmap(
valStops = c(0, 1, 2),
colStops = c("royalblue3", "white", "firebrick3"),
naCol = "gray"
)
valStops |
a vector listing the numerical values mapped to the color stops. Defaults to
|
colStops |
a vector of color strings. Defaults to |
naCol |
the color to assign to NA values. Defaults to "gray" |
a function accepting a numerical vector as input, which will produce the corresponding color vector.
mycolmap <- colmap(c(0,1,2),c("royalblue3","white","firebrick3"),naCol="gray")
mycolors <- mycolmap(seq(0,2,0.01))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.