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: enter image description here

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) 

enter image description here


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -