[R] heatmap

Roger Bivand Roger.Bivand at nhh.no
Tue Oct 4 10:58:52 CEST 2005


On Tue, 4 Oct 2005, Jim Lemon wrote:

> Andrea Zangrando wrote:
>  > 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.
>  >
> The color.gradient function in the plotrix package returns a sequence of 
> interpolated colors between any two starting colors or incomplete 
> sequences of primaries.
> 
> I noticed that a function named ramp (in the base package?) was 
> mentioned, but I could not find it. If there is a function equivalent to 
> color.gradient, I would like to know about it, as I try to avoid 
> duplicating functions.

see ?colorRamp and look at:

> colorRampPalette
function (colors, ...) 
{
    ramp <- colorRamp(colors, ...)
    function(n) {
        x <- ramp(seq(0, 1, length = n))
        rgb(x[, 1], x[, 2], x[, 3], max = 255)
    }
}

to see where it comes from. The colorRamp/colorRampPalette combination is 
quite remarkable and lots of fun ...

Roger

> 
> Jim
> 
> ______________________________________________
> R-help at 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
> 

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