[R] red-black-green color palette?

Earl F. Glynn efg at stowers-institute.org
Thu Aug 4 17:21:06 CEST 2005


"Jake Michaelson" <jjmichael at comcast.net> wrote in message
news:cbc7a1be7e3c68c0ccac507be8d3e7d8 at comcast.net...
> I'm working on some heatmaps, and the person I'm working with would
> prefer a red-black-green color palette (red denoting gene induction and
> green denoting gene repression).  Does such a palette exist already?
> If not, is there an easy way to create one?

Here are four ways:

showpanel <- function(Colors)
{
  image(matrix(1:length(Colors), ncol=1), col=Colors, xaxt="n", yaxt="n" )
}

oldpar <- par(mfrow=c(4,2))

# Method 1 (colorRampPalette was new in R 2.1.0) in grDevices
# Same as function with same name in dichromat package?
showpanel(colorRampPalette( c("green", "black", "red"), space="rgb")(32))
showpanel(colorRampPalette( c("green", "black", "red"), space="rgb")(64))

# Method 2
library(gplots)
showpanel(greenred(32))
showpanel(redgreen(64))

# Method 3
library(geneplotter)
showpanel(greenred.colors(32))
showpanel(greenred.colors(64))

# Method 4
library("marray")
pal <- maPalette(low="green", high="red",mid="black")
maColorBar(seq(-2,2, 0.2), col=pal, horizontal=TRUE, k=0)
maColorBar(seq(-2,2, 0.1), col=pal, horizontal=TRUE, k=0)


efg
--
Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research




More information about the R-help mailing list