2

我正在寻找一种方法来用 R(可能还有 ggplot2)复制下面显示的那种热表。具体时间轴无关;任何长方形桌子都应该这样做。

在此处输入图像描述

我尝试在 Google 中搜索Heat map和搜索Heat table,但找不到任何可以解决问题的 R 包。

想法?

4

1 回答 1

8
require(ggplot2)
df <- data.frame(vaxis = rep(c(letters[1:5], "top"), each = 4),
                 haxis = rep(c(letters[6:8], "right"), times = 6),
                 value = rpois(24, lambda = 10))
df$color <- factor(ifelse(df$vaxis == "top" | df$haxis == "right", 1, 0))
ggplot(df, aes(x = haxis, y = vaxis, size = value, color = color)) + geom_point()

只需以类似的格式获取您的数据。您可以编写一个函数来使“顶部”和“右侧”值标准化边际总和。当然,在命名、图例、主题等方面可以进行很多调整。

阴谋

于 2013-06-04T18:21:04.920 回答