colourpicker | R Documentation |
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)
x |
colour or colour palette name. Certe colours will be used from the certe.colours object. Input can be:
|
length |
size of the vector to be returned |
opacity |
amount of opacity (0 = solid, 1 = transparent) |
... |
not used at the moment |
white |
number between |
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.
character vector in HTML format (i.e., "#AABBCC"
) with new class colourpicker
colourpicker("certegroen")
colourpicker("certe", 5)
colourpicker(c("certeblauw", "red", "tan1", "#ffa", "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!")
colours <- colourpicker("R4", 6)
colours
add_white(colours, 0.25)
add_white(colours, 0.5)
add_white(colours, 0.75)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.