[R] Heatmap without levelplot

Antje niederlein-rstat at yahoo.de
Tue May 5 14:38:51 CEST 2009

Hi Uwe,

I tried to explain my problem with the given example.
I don't see any documentation which tells me that the length of "col.regions" 
should be one less than "at". (At least I assume now that it should be this way...)
If it's equal or longer some colors (in the middle of the color-vector) are 
simply not used.
Just try the example below with rainbow(5) and rainbow(6) and compare the 
results... both plot will use 5 colors!
Sorry, but this behaviour is not really self-explaining to me... maybe I'm to 
blind to find the documentation which says that only one color less will ensure 
the usage of all colors.

(It is so important for me because I need to display a heatmap with colors 
let's say
* all lower data outliers "green",
* all higher data outliers "blue" and
* everything else within the color range "yellow" to "red".
I've seen that some values do not get blue or green though they are outliers...
I've attached one graph, I've generated - maybe it helps to understand)

Any wrong assumption?


Uwe Ligges schrieb:
> Antje wrote:
>> Hi there,
>> as I'm not sure to understand the coloring levelplot uses, I'm looking 
>> for another easy way to create a heatmap like this:
>> library(lattice)
>> mat <- matrix(seq(1,5, length.out = 12), nrow = 3)
>> mat[1,2] <- 3.5
>> my.at <- seq(0.5,5.5, length.out = 6)
>> my.col.regions <- rainbow(5)
>> graph <- levelplot(t(mat[nrow(mat):1, ] ), at = my.at, col.regions = 
>> my.col.regions)
>> print(graph)
>> Can anybody help me with some hints or little examples?
> Dear Antje,
> since you are asking the same question again now, maybe you can explain 
> what you are going to get? In fact, I do not undertsand where your 
> problem is. R places the colors according to the values in your matrix 
> very well including the legend and I thought up to today that the plot 
> is self explaining.
> Best wishes,
> Uwe Ligges
>> Antje
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> 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