I wanted to do this before and always used to make two heat maps, and copy and paste one RowSideColors bar from one heat map to another. I just did a bit of work and found the heatmap.plus package that can do this, though:
# install.packages("heatmap.plus") #install package require("heatmap.plus") data(cars) # using cars data as example # create a matrix of colors for RowSideColors myCols = cbind(rep(c("yellow", "blue"), 25), rep(c("red", "green"), 25)) heatmap.plus(data.matrix(cars), RowSideColors=myCols)
The RowSideColors argument in this package can accept a color matrix to overlay multiple colors in a row.
source share