R 具有五种不同颜色的热图颜色键

R 具有五种不同颜色的热图颜色键,r,heatmap,R,Heatmap,我有以下代码,不知道如何使用它来显示热图,热图的颜色键显示五种不同的颜色,表示定义的值: 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") hm是R。我不确定他是否被允许与代表1进行编辑或评论…@JohanLun

我有以下代码,不知道如何使用它来显示热图,热图的颜色键显示五种不同的颜色,表示定义的值:

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")

hm是R。我不确定他是否被允许与代表1进行编辑或评论…@JohanLundberg我不相信这些代表限制适用于您自己的问题(或您自己问题的答案)。另外,我不认识
热图.2
功能,所以我在上搜索了它。他们可能会回答你的问题。@joran,我想他们的评论是…@JohanLundberg不,他们。谢谢你的帮助,shujaa。不知何故,颜色键中的颜色与预期的值不匹配;颜色键中根本没有出现黄色。非常感谢,Shujaa。这是一个完美的解决方案。legend()非常适合我的需要。非常感谢你的帮助!!!
<0.3 (blue)

0.3-1 (green)

1-1.3 (yellow)

1.3-3.0 (orange)

>3.0 (red)
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")
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"))