unikn (version 0.1.0)

usecol: Use a color palette.

Description

usecol allows using a color palette pal (e.g., for plotting).

Usage

usecol(pal = pal_unikn, n = "all", alpha = NA, use_names = FALSE,
  use_col_ramp = FALSE)

Arguments

pal

A color palette (as a vector of colors or color palettes). Default: pal = pal_unikn.

n

An integer value specifying the desired number of colors from the palette. For all palettes defined within unikn by default it uses a pre-defined selection of colors if the desired number of colors is smaller than the available number. For all other palettes and n larger than length(pal) it extends the palette using colorRampPalette.

alpha

A factor modifying the opacity alpha (as in adjustcolor); typically in [0,1]. Default: NA (i.e., no modification of opacity).

use_names

A logical value indicating whether colors should be returned as a named vector. (Defaults to FALSE for compatibility with ggplot).

use_col_ramp

A logical value specifying whether the default of using pre-selected colors should be overridden and colorRampPalette should be used to process n.

See Also

seecol to plot color palettes; pal_unikn for the default uni.kn color palette.

Other color functions: seecol

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataCamp Workspace