r - Emulate ggplot2 default color palette -
what function can use emulate ggplot2's default color palette desired number of colors. example, input of 3 produce character vector of hex colors these colors: 
it equally spaced hues around color wheel, starting 15:
gg_color_hue <- function(n) { hues = seq(15, 375, length = n + 1) hcl(h = hues, l = 65, c = 100)[1:n] } for example:
n = 4 cols = gg_color_hue(n) dev.new(width = 4, height = 4) plot(1:n, pch = 16, cex = 2, col = cols) 
Comments
Post a Comment