usecol {unikn} | R Documentation |
Use a color or color palette
Description
usecol
allows using a color or color palette pal
(e.g., for plotting).
Usage
usecol(
pal = pal_unikn,
n = "all",
alpha = NA,
distinct = FALSE,
use_names = FALSE,
use_col_ramp = FALSE
)
Arguments
pal |
A color palette (as a vector of colors or color palettes).
Default: |
n |
An integer value specifying the desired number of colors from the palette.
Default: |
alpha |
A factor modifying the opacity alpha
(as |
distinct |
Boolean: Return only visually distinct colors?
Default: |
use_names |
A logical value indicating whether colors should be returned as a named vector.
Default: |
use_col_ramp |
A logical value specifying whether the default of using pre-selected colors
should be overridden and |
Details
usecol
also allows modifying and combining color palettes in various ways.
Value
A (named) vector of colors (of type character).
See Also
seecol
for viewing and comparing color palettes;
simcol
for finding similar colors;
newpal
for defining new color palettes;
grepal
for finding named colors;
shades_of
to defining shades of a given color;
ac
for adjusting color transparency;
pal_unikn
for the default uni.kn color palette.
Other color functions:
ac()
,
demopal()
,
grepal()
,
newpal()
,
seecol()
,
shades_of()
,
simcol()
Examples
usecol(pal = pal_unikn, n = "all") # default color palette
usecol(pal = pal_unikn, n = 4) # selecting n dedicated colors
usecol(pal = pal_unikn, n = 20) # extending color palette
# Mixing a new color palette:
pal_1 <- usecol(pal = c(rev(pal_seeblau), "white", pal_pinky))
seecol(pal_1)
# Mixing and extending a color palette:
pal_2 <- usecol(pal = c(rev(pal_seegruen), "white", pal_bordeaux), n = 20)
seecol(pal_2)
# Defining and using a custom color palette:
pal_princeton_1 <- c("#E77500", "white", "black")
names(pal_princeton_1) <- c("orange_w", "white", "black")
pal_3 <- usecol(pal_princeton_1, n = 7)
seecol(pal_3)
# Removing visual duplicates:
usecol(c("black", "#000000", "gray", "grey", "red", "red1"), distinct = TRUE)
seecol(usecol(c(pal_unikn, pal_seeblau), distinct = TRUE), title = "Using distinct colors")