我正在使用 VennDiagram 包制作维恩图。他们出来了:
library(VennDiagram)
library(cowplot)
png("p.png")
p = draw.pairwise.venn(30,20,11, category = c("Dogs", "Cats"), lty = rep("blank", 2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(-45, 45), cat.dist = rep(0.025, 2))
dev.off()
png("q.png")
draw.pairwise.venn(15, 20, 10, category = c("Rats", "Mice"), lty = rep("blank", 2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(-45, 45), cat.dist = rep(0.025, 2))
dev.off()
但是,如果我尝试使用 cowplot 的 plot_grid() 将它们并排绘制,就会发生不好的事情:
p = draw.pairwise.venn(30,20,11, category = c("Dogs", "Cats"), lty = rep("blank", 2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(-45, 45), cat.dist = rep(0.025, 2))
q = draw.pairwise.venn(15, 20, 10, category = c("Rats", "Mice"), lty = rep("blank", 2), fill = c("light blue", "pink"), alpha = rep(0.5, 2), cat.pos = c(-45, 45), cat.dist = rep(0.025, 2))
png('pq.png')
plot_grid(p, q, labels = "AUTO")
dev.off()
Error: Argument needs to be of class "ggplot", "gtable", "grob", "recordedplot", or a function that plots to an R graphicsdevice when called, but is a gList
Calls: plot_grid -> align_plots -> lapply -> FUN -> plot_to_gtable
Execution halted
draw.pairwise.venn()
没有使对象与plot_grid()
.
class(p)
[1] "gList"
所以我想我需要将 gList 变成 ggplot 对象或其他兼容的东西,即使它gList
被列为合适的类型。我找不到任何东西。我想使用cowplot,因为它能够很好地标记要发布的子图。