heatmap.2 函数 R 的 ColSideColors 键

ColSideColors key for heatmap.2 function R

我浏览了 R 中 gplots 包中 heatmap.2() 函数的文档,寻找一种为 ColSideColors 参数编写颜色键的方法。这受支持吗?我想在输出图上显示每种颜色代表哪些级别。

legend R 中的函数可以帮助解决这个问题。

代码如下所示:

heatmap.2(mydata,ColSideColors=mycolors)
# ploting a heatmap
legend("left", title = "Tissues",legend=c("group1","group2"), 
       fill=c("red","green"), cex=0.8, box.lty=0)
# add a legend in which put your group text in legend, 
# and pass your colors which is used in heatmap.2 to fill.

你可以在这方面得到帮助tutorial