colors - R: reducing colour saturation of a colour palette -
i on lookout function reduces saturation of given colour palette amount. e.g. imagine have palette
library(colorramps) col.palette=colorramppalette(rainbow(13),interpolate ="spline")(1000) pie(rep(1,1000), col=col.palette,lty=0,labels=na)
is there function out there work on col.palette
colour vector, , cut down saturation amount, or allow brightness , contrast changed? (i trying accomplish rainbow palette less saturation , smoother transitions standard one)
edit: discovered function muted
in bundle scales
more or less want : http://www.inside-r.org/packages/cran/scales/docs/muted
as rainbow_hcl
in bundle colorspace
mentioned josh o'brien below, kind of more muted , equal intensity rainbow looking : http://www.inside-r.org/packages/cran/colorspace/docs/rainbow_hcl :
library(colorspace) pie(rep(1,1000), col=rainbow_hcl(1000,c=100,l=60),lty=0,labels=na)
here's function desaturate vector of input colors specified proportion:
library(colorspace) ## hsv colorspace manipulations library(rcolorbrewer) ## illustration colors ## function desaturating colors specified proportion desat <- function(cols, sat=0.5) { x <- diag(c(1, sat, 1)) %*% rgb2hsv(col2rgb(cols)) hsv(x[1,], x[2,], x[3,]) }
and here's illustration of looks in action:
## utility function plotting color palettes, ## (from vignette("hcl-colors")) pal <- function(col, border = "light gray", ...) { n <- length(col) plot(0, 0, type="n", xlim = c(0, 1), ylim = c(0, 1), axes = false, xlab = "", ylab = "", ...) rect(0:(n-1)/n, 0, 1:n/n, 1, col = col, border = border) } ## illustration colors cc <- brewer.pal(9, 'set1') cc75 <- desat(cc, 0.75) cc50 <- desat(cc, 0.50) cc25 <- desat(cc, 0.25) ## plot 'em par(mfcol = c(4,1), mar = c(0,0,0,0)) pal(cc) pal(cc75) pal(cc50) pal(cc25)
r colors
No comments:
Post a Comment