View source: R/color.palette.R
| color.palette | R Documentation |
Constructs a continuous color palette from a sequence of base colors. Intermediate colors are interpolated between each pair of adjacent colors, optionally using a custom number of interpolation steps.
color.palette(steps, n.steps.between = NULL, ...)
steps |
A character vector of base colors (e.g., hex codes or color names). These colors define the breakpoints in the palette. |
n.steps.between |
An optional integer vector specifying how many interpolated colors should
be added between each pair of entries in |
... |
Additional arguments passed to methods. |
This helper is primarily used for UME visualizations (e.g., color bars in density plots), but it can be used independently for any plotting task.
A function of class "colorRampPalette" that generates interpolated color
vectors when called with a single integer argument n.
For example, pal <- color.palette(c("blue", "white", "red")); pal(100)
returns a vector of 100 smoothly interpolated colors.
# Generate a simple blue-white-red palette
pal <- color.palette(c("blue", "white", "red"))
pal(10)
# Add additional steps between colors
pal2 <- color.palette(c("blue", "white", "red"), n.steps.between = c(5, 10))
pal2(20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.