在 ggpubr 中添加回层
Add back layers in ggpubr
我使用以下代码行从 ggpubr
图中删除了箱线图:
plot$layers <- plot$layers[-1]
我在这个堆栈上看到了这个解决方案 post:
我对 ggpubr
不太熟悉,但认为它适合这组特定的地块。有人告诉我删除箱线图,现在将其添加回去,现在我被卡住了。我在想我更改了环境设置,但不知道如何恢复到原来的方式。
非常感谢任何帮助!提供的图已删除药物名称。
剧情代码:
ggpar(ggpaired(data, x = "treatment", y = "value",
color = "treatment", palette = c("#202960", "#8CC63E"),
add = "dotplot", title = "Jiang (TIDE) CTL Panel - Mock vs. Drug",
xlab = "Treatment", ylab = "CTL Score",
width = 0, point.size = 2,
linetype = "dashed", line.color = "gray") +
stat_compare_means(method = "t.test", paired = TRUE,
label.x = 1.4, label.y = 1.8) +
#geom_text_repel(data = data %>% filter(treatment == "Mock"),
# aes(x = "Mock", y = value, label = subject),
# nudge_x = -0.2, inherit.aes = FALSE, size = 3,
# color = "#6c706d") +
scale_y_continuous(breaks = c(0,0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5),
labels = c("0","","0.5","","1.0","","1.5","","2.0","","2.5")) +
coord_cartesian(ylim = c(0,2)), legend = "FALSE")
当前绘图示例:
目标图示例(减去 geom_text_repel
标签):
代表:
data = structure(list(...1 = c("1", "2", "3", "4", "5", "6", "7", "1",
"2", "3", "4", "5", "6", "7"), subject = c("G5", "G6", "G7",
"G8", "G12", "G13", "G14", "G5", "G6", "G7", "G8", "G12", "G13",
"G14"), value = c(0.733377605384461, 1.65662450012502, 1.38787220722645,
1.37053666253192, 1.62679859595799, 0.541814589221617, 0.966081047005121,
0.892329475047538, 1.75954000718932, 1.36253416559681, 1.22104521047091,
1.61168414813187, 0.940537918248694, 1.00171611627718), treatment = c("Drug",
"Drug", "Drug", "Drug", "Drug", "Drug", "Drug", "Mock", "Mock",
"Mock", "Mock", "Mock", "Mock", "Mock")), row.names = c(NA, -14L
), class = "data.frame")
我最终重新安装了软件包并更改了宽度(width = 0.2
而不是 width = 0
),这给了我目标图。
我相信以下代码行会更改全局包设置,仅供参考:plot$layers <- plot$layers[-1]
编辑:没关系...我只是愚蠢...我想我的宽度为 0,这就是它看起来很有趣的原因。请无视我
我使用以下代码行从 ggpubr
图中删除了箱线图:
plot$layers <- plot$layers[-1]
我在这个堆栈上看到了这个解决方案 post:
我对 ggpubr
不太熟悉,但认为它适合这组特定的地块。有人告诉我删除箱线图,现在将其添加回去,现在我被卡住了。我在想我更改了环境设置,但不知道如何恢复到原来的方式。
非常感谢任何帮助!提供的图已删除药物名称。
剧情代码:
ggpar(ggpaired(data, x = "treatment", y = "value",
color = "treatment", palette = c("#202960", "#8CC63E"),
add = "dotplot", title = "Jiang (TIDE) CTL Panel - Mock vs. Drug",
xlab = "Treatment", ylab = "CTL Score",
width = 0, point.size = 2,
linetype = "dashed", line.color = "gray") +
stat_compare_means(method = "t.test", paired = TRUE,
label.x = 1.4, label.y = 1.8) +
#geom_text_repel(data = data %>% filter(treatment == "Mock"),
# aes(x = "Mock", y = value, label = subject),
# nudge_x = -0.2, inherit.aes = FALSE, size = 3,
# color = "#6c706d") +
scale_y_continuous(breaks = c(0,0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5),
labels = c("0","","0.5","","1.0","","1.5","","2.0","","2.5")) +
coord_cartesian(ylim = c(0,2)), legend = "FALSE")
当前绘图示例:
目标图示例(减去 geom_text_repel
标签):
代表:
data = structure(list(...1 = c("1", "2", "3", "4", "5", "6", "7", "1",
"2", "3", "4", "5", "6", "7"), subject = c("G5", "G6", "G7",
"G8", "G12", "G13", "G14", "G5", "G6", "G7", "G8", "G12", "G13",
"G14"), value = c(0.733377605384461, 1.65662450012502, 1.38787220722645,
1.37053666253192, 1.62679859595799, 0.541814589221617, 0.966081047005121,
0.892329475047538, 1.75954000718932, 1.36253416559681, 1.22104521047091,
1.61168414813187, 0.940537918248694, 1.00171611627718), treatment = c("Drug",
"Drug", "Drug", "Drug", "Drug", "Drug", "Drug", "Mock", "Mock",
"Mock", "Mock", "Mock", "Mock", "Mock")), row.names = c(NA, -14L
), class = "data.frame")
我最终重新安装了软件包并更改了宽度(width = 0.2
而不是 width = 0
),这给了我目标图。
我相信以下代码行会更改全局包设置,仅供参考:plot$layers <- plot$layers[-1]
编辑:没关系...我只是愚蠢...我想我的宽度为 0,这就是它看起来很有趣的原因。请无视我