我想在一个图中对三个不同的维恩图进行子图绘制。我正在使用R VennDiagram
包来获取维恩图。对于子图,我尝试了grid.arrange(),但它正在给出
" arrangeGrob"错误:" arrangeGrob错误(...,as.table = as.table, clip = clip,main = main ,:输入必须是grobs!"。
以下是我尝试的代码和我的R会话信息:
#VennDiagram:
library(VennDiagram)
A<- draw.pairwise.venn(600, 200, 61, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), sacled=FALSE)
B<- draw.pairwise.venn(400, 200, 60, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0,, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), scaled=FALSE)
C<- draw.pairwise.venn(700, 500, 75, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0,, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), scaled=FALSE)
#For subplot:
library(ggplot2)
library(grid)
library(gridExtra)
grid.arrange(A, B, C, ncol = 3, main = "Venn")
#R sessionInfo
sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] gridExtra_0.9.1 ggplot2_1.0.0 VennDiagram_1.6.9
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.6 gtable_0.1.2 MASS_7.3-35
[5] munsell_0.4.2 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.3
[9] reshape2_1.4.1 scales_0.2.4 stringr_0.6.2 tcltk_3.1.1
[13] tools_3.1.1
我非常感谢帮助绘制不同的维恩图作为子图。
答案 0 :(得分:0)
显然你已经解决了问题,但你也可以做(仅使用VennDiagram
和grid
个套餐):
pushViewport(viewport(layout=grid.layout(ncol=3, widths = unit(rep(1/3,3), "npc"))))
pushViewport(viewport(layout.pos.col=1))
draw.pairwise.venn(600, 200, 61, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), sacled=FALSE)
popViewport()
pushViewport(viewport(layout.pos.col=2))
draw.pairwise.venn(400, 200, 60, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0,, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), scaled=FALSE)
popViewport()
pushViewport(viewport(layout.pos.col=3))
draw.pairwise.venn(700, 500, 75, c("X", "Y"), col= rep("gray70", 2), lwd= rep (1, 2), fill= c("skyblue1", "yellowgreen"), cat.pos=0,, fontfamily = rep("sans"), cat.fontfamily= rep("sans"), scaled=FALSE)
popViewport(0)