[R] FW: color palette

From: Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI_at_saic.com>
Date: Fri 05 Aug 2005 - 05:36:45 EST

Try:

n   = 100;
x   = matrix(seq(-10, 30, length.out=500), ncol=1)
col = colorRampPalette( c("green", "white", "red"), space="rgb")(n) breaks =
c(seq(-10, 0, length.out=n/2)-0.5, 0, seq(0, 30, length.out=n/2)+0.5) image(x, col=col, breaks=breaks)

See also today's discussion on R-Help about "red-black-green color palette", since most of the code above came from Earl Glyn post.

Jarek

====================================================\=======

 Jarek Tuszynski, PhD.                           o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192                                   ">   \
 Jaroslaw.W.Tuszynski@saic.com                     `    \



-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of array chip Sent: Thursday, August 04, 2005 12:31 PM To: Thomas Lumley
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] color palette

Thanks for the suggestion. I still could not figure out how to use the function to do my job. What's important in my job is that I have to map white color to value 0, and then form a bue gradient for negative values, and red gradient for positive values. The data matrix I have is not symmetric aound 0, say 0 is at the 18 percentile, and values range from -10 to 30.
How exactly I could do my job? Bear with me, I am new to color, I don't quite understand how the image function map the number is the data matrix to the colors defined in the col argument.

Thanks

> On Wed, 3 Aug 2005, array chip wrote:
>
> > Hi, I have a matrix with both positive and
> negative
> > numbers, I would like to use image() to draw a heatmap. How can I
> > can design a palette (or is
> there a
> > function already available) that treat negative numbers in a blue
> > gradient and positive numbers in
> a
> > red gradient and treat 0 as white?
> >
>
> ?colorRampPalette
>
> -thomas
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Aug 05 05:47:13 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:04:49 EST