【问题标题】:R - heatmap, setting ColSideColorsR - 热图,设置 ColSideColors
【发布时间】:2015-04-07 08:24:09
【问题描述】:

我可以使用palette() 沿热图的行和列设置颜色标签吗? 我制作了一个随机的 4x4 矩阵,绘制热图并尝试设置侧面颜色:

m <- matrix(rnorm(16), 4, 4)
c <- c(1,1,2,2)
heatmap(m,ColSideColors=c)

我得到了错误:

"Error in heatmap(m, ColSideColors = c) : 
  'ColSideColors' must be a character vector of length ncol(x)"

【问题讨论】:

  • 你在错误信息中有答案。查看class(c) 的结果。请避免使用c 作为变量名。

标签: r colors heatmap


【解决方案1】:

来自?heatmap

ColSideColors(可选)长度为 ncol(x) 的字符向量,包含可用于注释 x 列的水平侧边栏的颜色名称。

set.seed(42)
m <- matrix(rnorm(16), 4, 4)
xsidecols <- c("#cdcd0d", "#0dcdcd", "#cd0dcd", "grey")
heatmap(m, ColSideColors = xsidecols)

【讨论】:

    猜你喜欢
    • 2021-10-25
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    • 1970-01-01
    相关资源
    最近更新 更多