[R] color scale mapped to B/W

hadley wickham h.wickham at gmail.com
Sat Jun 7 01:02:36 CEST 2008

On Fri, Jun 6, 2008 at 3:37 PM, Michael Friendly <friendly at yorku.ca> wrote:
> In an R graphic, I'm using
> cond.col <- c("green", "yellow", "red")
> to represent a quantitative variable, where green means 'OK', yellow
> represents 'warning'
> and red represents 'danger'. Using these particular color names, in B/W, red
> is darkest
> and yellow is lightest.  I'd like to find color designations to replace
> yellow and green so
> that when printed in B/W, the yellowish color appears darker than the
> greenish one.

An alternative approach would be to convert the colours into Luv,
adjust luminance appropriately and then convert back:

cond.col <- c("green", "yellow", "red")
col <- col2rgb(cond.col)
col.Luv <- convertColor(t(col), "sRGB", "Luv")
rownames(col.Luv) <- cond.col

col.Luv[, "L"] <- c(8000, 6000, 8000)
t(convertColor(col.Luv, "Luv", "sRGB"))

However, that doesn't actually seem to work - the back-transformed
colours are the same as the original.



More information about the R-help mailing list