[R] color palette from red to blue passing white

Ken Knoblauch knoblauch at lyon.inserm.fr
Tue Dec 4 21:55:57 CET 2007

hadley wickham <h.wickham <at> gmail.com> writes:
>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.
> > Package 'vcd' (and others) use package 'colorspace',
> > and I have wondered in the past if these color space computations
> > should not be merged into to standard R (package 'grDevices').
> > But that's really a topic for another thread, on R-devel, not R-help..
> 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
It's a good thought.
There is some thought going into standardizing, if 
you look at


and by the way, for a previous post, it's inaccurate to call Lab
"perceptual", although many people do.  It's based on discrimination data
in an attempt to make a uniform space for small color differences, 
but it is only approximately so.



PS, apologies that gmane is making me prune some quoted text

More information about the R-help mailing list