Skip to content
Prev 131245 / 398506 Next

color palette from red to blue passing white

Well I use them in ggplot2 :)  Unfortunately I've noticed that space =
"Lab" is much slower than space = "RGB" which is why I don't use Lab
space as a default.  And it also ignores alpha values, which is a bit
of a pain.
I find colour manipulation generally painful - all the really hard
stuff is there (i.e. conversion between colour spaces), but convenient
functions are lacking.   For example, I have this alpha function in
ggplot:

alpha <- function(colour, alpha) {
  col <- col2rgb(colour, TRUE) / 255
  col[4, ] <- rep(alpha, length(colour))

  new_col <- rgb(col[1,], col[2,], col[3,], col[4,])
  new_col[is.na(colour)] <- NA
  new_col
}

which seems like a lot of work for a simple task.  The fact that
col2rgb and rgb aren't symmetric is frustrating, especially since one
outputs values between 0 and 255 and the other (by default) accepts
inputs between 0 and 1.
It would definitely be nice if all colour space manipulations were
merged into a single package, with a consistent interface.  I would
happily contribute to such a project, since I do a lot of colour
manipulation in ggplot.

Hadley