The simplest way is to just reverse the vector of heat colors:
heatmap(m, Rowv=NA, Colv=NA, col = rev(heat.colors(256)),
scale="none", margins=c(5,5), na.rm=T)
Question
I have a heatmap that contains a lot of 1s and a few 0s
R) m = matrix(rep(1,25),5,5)
R) m[c(1,5,7,8,3,5)] = 0
R) m
[,1] [,2] [,3] [,4] [,5]
[1,] 0 1 1 1 1
[2,] 1 0 1 1 1
[3,] 0 0 1 1 1
[4,] 1 1 1 1 1
[5,] 0 1 1 1 1
R) heatMap <- heatmap(m, Rowv=NA, Colv=NA, col = heat.colors(256), scale="none", margins=c(5,5), na.rm=T)
In the heat map I need scale='none'
as I have sometimes matrices with only 1 or 0 (and scaling fail in that case), how can I make the heatmap to get darker colors for higher numbers ?
Solution
The simplest way is to just reverse the vector of heat colors:
heatmap(m, Rowv=NA, Colv=NA, col = rev(heat.colors(256)),
scale="none", margins=c(5,5), na.rm=T)