[R] heatmap

Roger Bivand Roger.Bivand at nhh.no
Mon Oct 3 15:00:51 CEST 2005


On Mon, 3 Oct 2005, Romain Francois wrote:

> Le 03.10.2005 14:24, Andrea Zangrando a écrit :
> 
> >Hi,
> >i created a graph with heatmap(sma) function:
> >
> >heatmap(dataHeat(x))
> >
> >and I wish to change the gradation of colors from blue to red, how could 
> >i do?
> >Using "heatmap(dataHeat(x), col=c(2,4))" i will use only 2 colors 
> >without gradation.
> >
> >Ty so much
> >Andrea
> >  
> >
> Hello,
> 
> Check bluered() in the gplots package.

Or roll your own in base:

> myBlRd <- colorRampPalette(c("blue", "red"))
> myBlRd
function (n) 
{
    x <- ramp(seq(0, 1, length = n))
    rgb(x[, 1], x[, 2], x[, 3], max = 255)
}
<environment: 0x9a5792c>
> myBlRd(15)
 [1] "#0000FF" "#1200EC" "#2400DA" "#3600C8" "#4800B6" "#5B00A3" "#6D0091"
 [8] "#7F007F" "#91006D" "#A3005B" "#B60048" "#C80036" "#DA0024" "#EC0012"
[15] "#FF0000"


> 
> Romain
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list