【问题标题】:Is there a way to insert custom text into a heatmap.2?有没有办法将自定义文本插入到 heatmap.2 中?
【发布时间】:2020-10-23 10:46:59
【问题描述】:

我正在使用 heatmap.2 来制作热图。有时我想在一个单元格元素中插入一个星号来表示这个元素在统计上是显着的。重要性已在另一个程序中计算。有没有办法将自定义文本或图形元素(星号)插入到 heatmap.2 热图中?

【问题讨论】:

    标签: r heatmap


    【解决方案1】:

    您可以使用heatmap.2 的参数cellnote(将放置在每个颜色单元格内的字符串矩阵,例如p值符号)。

    library(gplots)
    
    # A 4 x 4 matrix
    x <- as.matrix(dist(t(iris[,-5])))
    
    # A 4 x 4 matrix of characters (stars)
    labs <- matrix("",4,4)
    labs[2,3] <- labs[1,4] <- "*"
    
    # How to use cellnote
    p <- heatmap.2(x, cexRow=.8, cexCol=.8, 
                   cellnote=labs, notecol="black", notecex=10)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-04
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      • 2019-11-28
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多