View source: R/utility_functions.R
categoricalColPal | R Documentation |
Generate categorical ColorBrewer palette. Specify one of 'labels' or 'n' to generate categorical color palette for use with 'scale_fill_manual(values = col.pal)' and 'scale_color_manual(values = col.pal)'
categoricalColPal(labels = NULL, n = NULL, palette = "Spectral")
labels |
vector of category names that if specified will have color assigned to. Default is NULL. |
n |
number of colors. Default is NULL. Ignored if 'labels' is specified. |
palette |
Name of palette. Default: "Spectral" |
Vector of colors. Named if labels provided.
Nicholas Mikolajewicz
# generate color palette
col.pal <- categoricalColPal(n = 10)
# add to ggplot handle
gg.plt <- gg.plt + scale_fill_manual(values = col.pal)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.