Description Usage Arguments Examples
Display colors in the viewer
1 2 3 4 5 |
colors |
A vector of colors |
width |
Width of each box. |
height |
Height of each box |
pal |
A function for generating a palette. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ### View colors
# Scale of greys
view_cols(c("#ffffff", "#e3e3e3", "#c6c6c6", "#aaaaaa",
"#8e8e8e", "#717171", "#555555", "#393939",
"#1c1c1c", "#000000"))
# 50 first colors from colors() (converted to HEX first)
col2hex <- function(col, alpha) # function from @davidorme
rgb(t(col2rgb(col)), alpha=alpha, maxColorValue=255)
view_cols(col2hex(colors()[1:50]))
### View palettes
# View one palette
view_pal(pal = chroma_continuous_pal())
view_pal(pal = chroma_continuous_pal(mode = "lch"))
# View several palettes
view_pal(pal = list(
"default (mode lab)" = chroma_continuous_pal(),
"mode lch" = chroma_continuous_pal(mode = "lch"),
"mode rgb" = chroma_continuous_pal(mode = "rgb")
))
# View scales palettes
library(scales)
view_pal(pal = list(
"seq_gradient_pal" = seq_gradient_pal(),
"gradient_n_pal" = gradient_n_pal(c("yellow", "navy"))
))
### View a gradient
x <- seq(0, 1, length.out = 100)
view_gradient(chroma_continuous_pal()(x))
# with a list
view_gradient(list(
"chroma" = chroma_continuous_pal()(x),
"bezier" = bezier_continuous_pal()(x)
))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.