gpt4 book ai didi

r - R 中的加热表

转载 作者:行者123 更新时间:2023-12-02 07:03:10 27 4
gpt4 key购买 nike

我正在寻找一种方法来用 R(可能还有 ggplot2)复制下面显示的那种热表。具体时间轴无关;任何矩形 table 都可以。

enter image description here

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

想法?

最佳答案

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()

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

plot

关于r - R 中的加热表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16924554/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com