require(gplots)
require(RColorBrewer)
## Some fake data for you
data_matrix <- matrix(runif(100, 0, 3.5), 10, 10)
## The colors you specified.
myCol <- c("blue", "green", "yellow", "orange", "red")
## Defining breaks for the color scale
myBreaks <- c(0, .3, 1, 1.3, 3, 3.5)
hm <- heatmap.2(data_matrix, scale="none", Rowv=NA, Colv=NA,
col = myCol, ## using your colors
breaks = myBreaks, ## using your breaks
dendrogram = "none", ## to suppress warnings
margins=c(5,5), cexRow=0.5, cexCol=1.0, key=TRUE, keysize=1.5,
trace="none")
这应该可行,并为您提供一些有关如何进一步编辑它的想法,如果您愿意的话。要获得具有确切值的图例,我不会打扰内置的直方图,而是只使用legend
:
hm <- heatmap.2(data_matrix, scale="none", Rowv=NA, Colv=NA,
col = myCol, ## using your colors
breaks = myBreaks, ## using your breaks
dendrogram = "none", ## to suppress warnings
margins=c(5,5), cexRow=0.5, cexCol=1.0, key=FALSE,
trace="none")
legend("left", fill = myCol,
legend = c("0 to .3", "0.3 to 1", "1 to 1.3", "1.3 to 3", ">3"))