I am relatively new to R and am trying to use heatmap.2(). I have found it to be a great tool, except there is one detail that is driving me crazy. The tick marks in the legend do not line up perfectly with the colors I assign in the breaks.
Below is a minimal working example. In the legend the green area goes significantly over 1, however the bottom left portion of the heatmap (value = 1.0001) is blue as I specified in the breaks. I am using RStudio Version 0.99.486 if that makes a difference. Please help!
library(gplots)
M <- matrix(c(0.5,1.0001,2.1,3.9),nrow=2)
my_palette <- c('green','blue','purple','orange')
heatmap.2(M,Colv=NULL,Rowv=FALSE,dendrogram=NULL,trace='none',density.info='none',
breaks=c(0,1,2,3,4),
col=my_palette,
key.xlab='',key.title='')