[R] Heatmap Colors

Nick Fankhauser lists at nyk.ch
Sat Sep 29 00:16:21 CEST 2012


Hello R-Users!

I'm using a heatmap to visualize a matrix of values between -1 and 3.
How can I set the colors so that white is zero, below zero is blue of 
increasing intensity towards -1 and above zero is red of increasing 
intensity towards red?

I tried like this (using the marray and gplots packages from bioconductor):
mcol <- maPalette(low="blue", mid="white", high="red",k=100)
heatmap.2(my_matrix, col=mcol)

But white does not correspond to zero, because the value distribution is 
not symmetrical, so that zero is not in the middle.
Is it somehow possible to create a color palette with white centered at 
zero?

Nick Fankhauser



More information about the R-help mailing list