Skip to Content

Heatmap color key with five different colors

I have the following code and not sure how to use it to display a heatmap with a color key displaying five different colors representing defined values:

hm <- heatmap.2(data_matrix, scale="none",Rowv=NA,Colv=NA,col = rev(brewer.pal(11,"RdBu")),margins=c(5,5),cexRow=0.5, cexCol=1.0,key=TRUE,keysize=1.5, trace="none")

Color key required:

<0.3 (blue)
0.3-1 (green)
1-1.3 (yellow)
1.3-3.0 (orange)
>3.0 (red)

I would be happy if someone can help. Thanks!