[R] color scale mapped to B/W
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Sat Jun 7 01:23:21 CEST 2008
On Fri, 6 Jun 2008, Michael Friendly 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.
>
> Is there some tool/code I can use to find these? i.e., something to display a
> grid
> of color swatches with color codes/names I can look at in color and B/W to
> decide?
You could look at colors in HCL (i.e., polar LUV). For example, you could
choose a dark red HCL = (0, 90, 40) and a light green (120, 70, 90) and a
yellow somewhere in between.
To emulate what happens when you print that out, you just set the chroma
to zero.
There are some functions helpful for that in "vcd", you could do
## load package
library("vcd")
## select colors from dark red to light green
c1 <- heat_hcl(3, h = c(0, 120), c = c(90, 70), l = c(40, 90), power=1.7)
c2 <- heat_hcl(3, h = c(0, 120), c = 0, l = c(40, 90), power=1.7)
## visualize in color and grayscale emulation
plot(-1, -1, xlim = c(0, 1), ylim = c(0, 2), axes = FALSE)
rect(0:2/3, 0, 1:3/3, 1, col = c1, border = "transparent")
rect(0:2/3, 1, 1:3/3, 2, col = c2, border = "transparent")
The ideas underlying this color choice are described in this report we've
written together with Kurt and Paul:
http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87
hth,
Z
> thanks,
>
>
> --
> Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology
> Dept.
> York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
> 4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
> Toronto, ONT M3J 1P3 CANADA
>
> ______________________________________________
> 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.
>
>
More information about the R-help
mailing list