我正在使用R draw.pairwise.venn
绘制维恩图。我想在一个图中添加许多维恩图,并为每个图添加不同的标题。
这是我的代码。
library(VennDiagram)
library(gridExtra)
g = draw.pairwise.venn(88, 3852, 86, category = c('A', 'B'), lty = rep("blank",2), fill = c("red", " navyblue"), alpha = rep(0.5, 2), cat.pos = c(0,0), cat.dist = rep(0.025, 2, euler.d=TRUE, scaled=TRUE, ind = FALSE))
g1 = draw.pairwise.venn(98, 3812, 56, category = c('A', 'B'), lty = rep("blank",2), fill = c("red", " navyblue"), alpha = rep(0.5, 2), cat.pos = c(0,0), cat.dist = rep(0.025, 2, euler.d=TRUE, scaled=TRUE, ind = FALSE))
grid.arrange(gTree(children=g),gTree(children=g1), top=c("Central Asia","Africa"))
但是,这只给了我仅次于中亚的头衔。 谁能在这件事上帮助我?
答案 0 :(得分:3)
您可以使用plot_grid
中的cowplot
添加单个标签:
cowplot::plot_grid(gTree(children = g), gTree(children = g1),
labels = c("Central Asia","Africa"))
答案 1 :(得分:0)
VennDiagram
包已经有一个用于添加标题的参数。当您使用 draw.pairwise.venn()
绘制图表时,只需包含 main = "Central Asia"
作为参数。在您的情况下,它将如下所示:
g = draw.pairwise.venn(88, 3852, 86, category = c('A', 'B'), lty = rep("blank",2), main = "Central Asia", fill = c("red", " navyblue"), alpha = rep(0.5, 2), cat.pos = c(0,0), cat.dist = rep(0.025, 2, euler.d=TRUE, scaled=TRUE, ind = FALSE))