Colours from R, Certe, viridis and more. The output prints in the console with the actual colours.

colourpicker(x, length = 1, opacity = 0, ...)

# S3 method for class 'colourpicker'
as.character(x, ...)

# S3 method for class 'colourpicker'
print(x, ...)

add_white(x, white)

Arguments

x

colour or colour palette name. Certe colours will be used from the certe.colours object. Input can be:

  • "certe"

  • "certe0" to "certe6" (higher numbers give lighter colours)

  • "certeblauw", "certegroen", "certeroze", "certegeel", "certelila", or "certebruin" (or any of these followed by a 0 to 6)

  • "certe_sir" or "certe_sir2" for certeroze/certegeel/certegroen (will always return length 5, with names "S", "SI", "I", "IR", "R")

  • One of the colourblind-safe viridisLite palettes:

    • "viridis"

    • "magma"

    • "inferno"

    • "plasma"

    • "cividis"

    • "rocket"

    • "mako"

    • "turbo"

  • One of the built-in palettes in R (currently R 4.4.1):

    • "R3"

    • "R4"

    • "ggplot2"

    • "Okabe-Ito"

    • "Accent"

    • "Dark 2"

    • "Paired"

    • "Pastel 1"

    • "Pastel 2"

    • "Set 1"

    • "Set 2"

    • "Set 3"

    • "Tableau 10"

    • "Classic Tableau"

    • "Polychrome 36"

    • "Alphabet"

    • "topo"

    • "heatmap"

    • "rainbow"

    • "terrain"

    • "greyscale"

    • "grayscale"

  • One of the 657 built-in colours() in R, such as "azure3", "chocolate4", "darkolivegreen", "seagreen", "steelblue1"

length

size of the vector to be returned

opacity

amount of opacity (0 = solid, 1 = transparent)

...

not used at the moment

white

number between [0, 1] to add white to x

Value

character vector in HTML format (i.e., "#AABBCC") with new class colourpicker

Details

Certe colours will be chosen as divergent as possible if the required output length is not too high. For example:

  • x = "certe" tries to only return the "certe" colours ("certeblauw", "certegroen", ...), the "certe3" colours ("certeblauw3", "certegroen3", ...) and the "certe5" colours ("certeblauw5", "certegroen5", ...)

  • x = "certe2" tries to only return the regular "certe2" colours ("certeblauw2", "certegroen2", ...), the "certe4" colours ("certeblauw4", "certegroen4", ...) and the "certe6" colours ("certeblauw6", "certegroen6", ...)

  • x = "certe3" tries to only return the "certe3" colours ("certeblauw3", "certegroen3", ...) and the "certe5" colours ("certeblauw5", "certegroen5", ...)

When using a single Certe colour with length > 1, a palette will be generated based on \*, \*2, \*3, \*4, and \*5. For example, colourpicker("certeblauw", 5) will return the colours "certeblauw", "certeblauw2", "certeblauw3", "certeblauw4", and "certeblauw5".

A palette from R will be expanded where needed, so even colourpicker("R4", length = 20) will work, despite "R4" only supporting a maximum of eight colours.

Examples

colourpicker("certegroen")
#> [1] "#93984C"  
colourpicker("certe", 5)
#> [1] "#4A647D"  "#93984C"  "#B4527F"  "#E4D559"  "#CEB9D6"  
colourpicker(c("certeblauw", "red", "tan1", "#ffa", "FFAA00"))
#> [1] "#4A647D"  "#FF0000"  "#FFA54F"  "#FFFFAA"  "#FFAA00"  

par(mar = c(0.5, 2.5, 1.5, 0)) # set plot margins for below plots

# Certe colours
barplot(12:1,
        col = colourpicker("certe", 12),
        main = "'certe': uses 'certe' + 'certe3'")

barplot(12:1,
        col = colourpicker("certe2", 12),
        main = "'certe2': uses 'certe2' + 'certe4'")

barplot(12:1,
        col = colourpicker("certe3", 12),
        main = "'certe3': uses 'certe3' + 'certe5'")

barplot(5:1,
        col = colourpicker("certeblauw", 5),
        main = "'certeblauw'")

barplot(12:1,
        col = colourpicker("certeblauw", 12),
        main = "'certeblauw': auto-extended range")


# all colourblind-safe colour palettes from the famous viridisLite package
barplot(1:7,
        col = colourpicker("viridis", 7))

barplot(1:7,
        col = colourpicker("magma", 7))


barplot(8:1,
        col = colourpicker("R4", 8),
        main = "Some palettes have only 8 colours...")

barplot(20:1,
        col = colourpicker("R4", 20),
        main = "Not anymore!")
#> Warning: Colour palette expanded using grDevices::colorRampPalette()



colours <- colourpicker("R4", 6)
colours
#> [1] "#000000"  "#DF536B"  "#61D04F"  "#2297E6"  "#28E2E5"  "#CD0BBC"  
add_white(colours, 0.25)
#> [1] "#3F3F3F"  "#E77E90"  "#88DB7B"  "#59B1EC"  "#5DE9EB"  "#D948CC"  
add_white(colours, 0.5)
#> [1] "#7F7F7F"  "#EFA9B5"  "#B0E7A7"  "#90CBF2"  "#93F0F2"  "#E685DD"  
add_white(colours, 0.75)
#> [1] "#BFBFBF"  "#F7D4DA"  "#D7F3D3"  "#C7E5F8"  "#C9F7F8"  "#F2C2EE"