如何在热图中调整颜色图例的位置

时间:2017-05-24 11:29:39

标签: r heatmap gplots

我正在尝试使用以下代码进行无偏的分层聚类

col.cell <- c("purple","orange", "green", "blue")[sampleinf$subtype]
heatmap.2(as.matrix(hm3),col=rev(morecols(50)),trace="none", main="Top 500 most variable genes across samples",ColSideColors=col.cell,scale="row")  
    legend("topright",      
    legend = unique(sampleinf$subtype),
    col = col.cell,     
    lty= 1.5,   lwd = 2,           
    cex=.6)

如何使颜色图例更加醒目。现在它与树形图叠加。

undefined behavior

1 个答案:

答案 0 :(得分:0)

要绘制在0到1范围之外,您需要使用par(xpd = TRUE)

 legend(x = #,y= #, xpd = TRUE, legend("topright",      
    legend = unique(sampleinf$subtype),
    col = col.cell,     
    lty= 1.5,   lwd = 2,           
    cex=.6)