基于值的颜色和点内的值编号的气球图
Balloon plots with colours based on value and with value number inside the dots
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))
我将不胜感激 suggestion/help,并对我的 R 技能不佳感到抱歉。
您需要在 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)
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))
我将不胜感激 suggestion/help,并对我的 R 技能不佳感到抱歉。
您需要在 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)