color_palette(n = 10, palette = "nest")(numeric value)
The number of colors to be returned from
the color palettes. Please note the colors will be repeated after
a certain numerical limit per palette:
nest 96 colors
stream 38 colors
viridis 49 colors
accessible 18 colors
(character value)
The name of a palette supported by this function
nest A color palette developed by the NEST team representing colors in the NEST logo.
stream A color palette proposed by the stream documentation of stream version 2_05
viridis A color palette provided by the viridis::plasma function.
accessible A color palette consisting of accessible colors for those with color blindness.
A list of hex color code
library(grid)
plot_pal <- function(x) {
grid.newpage()
pushViewport(plotViewport(rep(1, 4)))
pushViewport(viewport(layout = grid.layout(1, ncol = length(x))))
for (i in seq_along(x)) {
grid.rect(
gp = gpar(fill = x[i], col = NA),
vp = viewport(layout.pos.col = i, layout.pos.row = 1)
)
}
}
plot_pal(color_palette(n = 10, palette = "nest"))
plot_pal(color_palette(n = 10, palette = "stream"))
plot_pal(color_palette(n = 10, palette = "viridis"))
plot_pal(color_palette(n = 10, palette = "accessible"))