r - ggplot2 中是否可以使用 "sized dot style"中的热图?

标签 r ggplot2 heatmap

是否可以在 ggplot2 中用圆形而不是方形绘制热图?不仅可以通过颜色渐变来表示值,还可以通过圆的大小来表示这些值。
我在想这样的图 dot heatmap其中圆圈大小也按其特定值交替。我已经用 ggplot2 阅读了热图,但找不到解决方案。对于热图,我将 learnr.wordpress.com 上发布的示例替换为:

 library(ggplot2)
 library(plyr)
 library(reshape2)
 library(scales)
 kreuz <- read.csv("http://datasets.flowingdata.com/ppg2008.csv")
 kreuz.m <- melt(kreuz)
 (p <- ggplot(kreuz.m, aes(Name, variable)) +
   geom_tile(aes(fill = value), colour = "white") +
   scale_fill_gradient2(breaks=waiver(), name="binding strength", 
      low ="white", mid= ("lightblue"), high = "steelblue", midpoint = 4))
 base_size <- 10
 p + theme_grey(base_size = base_size) +
   theme(panel.grid.major = element_blank())+
   labs(x = "Patient ID", y = "Phage Motives", title = "Cross Reactivity")+
   scale_x_discrete(expand = c(0, 0)) +
   scale_y_discrete(expand = c(0, 0)) +
   theme(legend.position = "right", axis.ticks = element_blank(), 
      axis.text.x = element_text(size = base_size *0.8, angle = 270, hjust = 0,
      colour = "grey50"))+
   labs(x = "Patient ID", y = "Phagemotives", title = "cross reactivity")

我会非常感谢一些提示!

最佳答案

在此示例中,大小和颜色都对应于变量值,因为它是 kreuz.m 数据集中唯一可用的变量数字。

ggplot(kreuz.m, aes(Name, variable)) +
  geom_point(aes(size = value, colour=value))

关于r - ggplot2 中是否可以使用 "sized dot style"中的热图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19358297/

相关文章:

r - 热图颜色在绘图中不起作用

r - 我想根据同一数据框中其他列的条件从 R 数据框中的列生成 8 种名称组合

.net - .NET session 变量是否有 R Shiny 等效项?

r - 将 lm 添加到 ggplot2 中的日期时间数据时出错

rgb() 与 R 中的 ggplot2

r - Shiny 和 ggplot2 - 教程

python - 具有来自表文件的重采样日期时间的交叉表数据框

r - 在 R 数据框中添加一个新列,其值以另一列的值为条件

r - position_dodge 和 nudge_y 在一起

python - Python 中的空间数据热图