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?
t hanks,
--
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
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/
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. > >
Try this (you need tcl 8.5 and the TeachingDemos package):
library(teachingDemos)
tmpplot <- function(col1='red', col2='yellow',
col3='green'){
plot(1:10,1:10, type='n')
rect(1,1,4,4, col=col1)
rect(1,4,4,7, col=col2)
rect(1,7,4,10, col=col3)
rect(6,1,9,4, col=col2grey(col1))
rect(6,4,9,7, col=col2grey(col2))
rect(6,7,9,10, col=col2grey(col3))
text(5, c(2,5,8), c(col1, col2, col3))
}
cols <- colors()[ -c( 152:253, 260:361) ]
tkexamp( tmpplot(), list(col1=list('combobox', values=cols,
init='red'),
col2=list('combobox',values=cols, init='yellow'),
col3=list('combobox',values=cols, init='green') ) )
Hope it helps,
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On
Behalf Of Michael Friendly [friendly at yorku.ca]
Sent: Friday, June 06, 2008 2:37 PM
To: R-Help
Subject: [R] color scale mapped to B/W
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?
t hanks,
--
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.
You may also want to look at the "show.colors" function in the
"DAAG" package to get candidate colors.
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On
Behalf Of Michael Friendly [friendly at yorku.ca]
Sent: Friday, June 06, 2008 2:37 PM
To: R-Help
Subject: [R] color scale mapped to B/W
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?
t hanks,
--
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.