structure(list(Patients = c("LT2", "LT2", "LT2", "LT2", "LT2",
"LT2", "LT2", "LT2", "LT2", "LT2", "LT3", "LT3", "LT3", "LT3",
"LT3", "LT3", "LT3", "LT3", "LT3", "LT3", "LT4", "LT4", "LT4",
"LT4", "LT4", "LT4", "LT4", "LT4", "LT4", "LT4", "LT5", "LT5",
"LT5", "LT5", "LT5", "LT5", "LT5", "LT5", "LT5", "LT5"), Cell_type = c("CD3 T cells",
"CD4 T cells", "CD8 T cells", "NKT cells", "CD14 monocytes",
"CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells", "Eosinophils",
"Neutrophils", "CD3 T cells", "CD4 T cells", "CD8 T cells", "NKT cells",
"CD14 monocytes", "CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells",
"Eosinophils", "Neutrophils", "CD3 T cells", "CD4 T cells", "CD8 T cells",
"NKT cells", "CD14 monocytes", "CD19 B cells", "CD56 dim NK cells",
"CD56 high NK cells", "Eosinophils", "Neutrophils", "CD3 T cells",
"CD4 T cells", "CD8 T cells", "NKT cells", "CD14 monocytes",
"CD19 B cells", "CD56 dim NK cells", "CD56 high NK cells", "Eosinophils",
"Neutrophils"), Value = c(25.6, 61.8, 27.2, 4.94, 1.92, 11.1,
7.39, 42.8, 4.39, 42.9, 19.8, 65.3, 29.1, 2.87, 1.68, 1.99, 6.23,
60.7, 4.7, 61.5, 20.3, 81, 16.2, 0.25, 1.09, 3.3, 7.07, 61.9,
4.96, 61.6, 29.4, 76.2, 20.8, 1.47, 1.3, 3.92, 11.3, 35.3, 1.18,
51.3)), class = "data.frame", row.names = c(NA, -40L))大家好,我想知道是否有人可以帮助制作气球图,气球图的颜色基于值,值数字在点上。我无法在R中下载ggballoonplot,即使ggplot2已经更新。
我运行以下代码,但只能得到黑色气球图。
Immunoph <- read.csv("LS-Pts_csv.csv", header = T)
names(Immunoph)[names(Immunoph) =="Freq"] <-"Value"
head(Immunoph)
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1))我非常感谢任何建议/帮助,并为我在R方面的糟糕技能感到抱歉。
发布于 2021-05-15 02:11:03
您需要在aes中使用color = Value并添加一个geom_text()调用:
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type, color = Value))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1)) +
geom_text(label=Immunoph$Value, color="black")为您提供:

尽管如果你轻推文本,它看起来会更好:
p <- ggplot(Immunoph, aes(x=Patients, y=Cell_type, color = Value))
p+geom_point(aes(size=Value)) +theme(panel.background = element_blank(),
panel.border =element_rect(colour = "blue", fill = NA, size = 1)) +
geom_text(label=Immunoph$Value, color="black", nudge_x = 0.2)

https://stackoverflow.com/questions/67538110
复制相似问题