是否可以在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")
我会非常感谢一些提示!
答案 0 :(得分:1)
在此示例中,大小和颜色都与变量值对应,因为它是kreuz.m数据集中唯一可用的变量数字。
ggplot(kreuz.m, aes(Name, variable)) +
geom_point(aes(size = value, colour=value))