| palette_colors | R Documentation |
This function creates a color palette for a given vector of values.
palette_colors(
x,
n = 100,
palette = "Paired",
palcolor = NULL,
type = c("auto", "discrete", "continuous"),
matched = FALSE,
reverse = FALSE,
NA_keep = FALSE,
NA_color = "grey80"
)
x |
A vector of character/factor or numeric values. If missing, numeric values 1:n will be used as x. |
n |
The number of colors to return for numeric values. |
palette |
Palette name. All available palette names can be queried with show_palettes. |
palcolor |
Custom colors used to create a color palette. |
type |
Type of |
matched |
Whether to return a color vector of the same length as |
reverse |
Whether to invert the colors.
Default is |
NA_keep |
Whether to keep the color assignment to NA in |
NA_color |
Color assigned to NA if |
A character vector of color codes (hexadecimal format) corresponding to the input values x. The length and structure depend on the matched parameter.
show_palettes, palette_list
x <- c(1:3, NA, 3:5)
(pal1 <- palette_colors(
x,
palette = "Spectral"
))
(pal2 <- palette_colors(
x,
palcolor = c("red", "white", "blue")
))
(pal3 <- palette_colors(
x,
palette = "Spectral",
n = 10
))
(pal4 <- palette_colors(
x,
palette = "Spectral",
n = 10,
reverse = TRUE
))
(pal5 <- palette_colors(
x,
palette = "Spectral",
matched = TRUE
))
(pal6 <- palette_colors(
x,
palette = "Spectral",
matched = TRUE,
NA_keep = TRUE
))
show_palettes(
list(pal1, pal2, pal3, pal4, pal5, pal6)
)
# Use Chinese color palettes
palette_colors(
x = letters[1:5],
palette = "ChineseRed",
type = "discrete"
)
palette_colors(
x = letters[1:5],
palette = "Chinese",
type = "discrete"
)
all_palettes <- show_palettes(return_palettes = TRUE)
names(all_palettes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.