【问题标题】:how to adjust the position of color legends in heatmap.2如何调整heatmap.2中颜色图例的位置
【发布时间】:2017-05-24 11:29:38
【问题描述】:

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

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)

如何使颜色图例更明显。现在它与树状图叠加。

【问题讨论】:

    标签: r heatmap gplots


    【解决方案1】:

    要在 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-04
      • 2013-07-23
      相关资源
      最近更新 更多