[R] color scale mapped to B/W

Greg Snow Greg.Snow at imail.org
Sat Jun 7 01:27:09 CEST 2008

Try this (you need tcl 8.5 and the TeachingDemos package):

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
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