Re: [R] color scale mapped to B/W

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 06 Jun 2008 18:02:36 -0500

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.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 06 Jun 2008 - 23:06:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 06 Jun 2008 - 23:30:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive