我想把这三个维恩图放在一起。因此,当我打印它们时,它们出现在同一页面中
library(VennDiagram)
df1 <- data.frame(G1=sample(1:100, 10), G2=sample(1:100, 10),
G3=sample(1:100, 10), G4=sample(1:100, 10))
venn.plot.df1 <- venn.diagram(x = as.list(df1), filename = NULL,
cat.col = c( "black", "red", "green3", "blue" ),
fill=c("black", "red", "green3", "blue"))
grid.draw(venn.plot.df1)
df2 <- data.frame(G1=sample(1:100, 10), G2=sample(1:100, 10),
G3=sample(1:100, 10), G4=sample(1:100, 10))
venn.plot.df2 <- venn.diagram(x = as.list(df2), filename = NULL,
cat.col = c( "black", "red", "green3", "blue" ),
fill=c("black", "red", "green3", "blue"))
grid.draw(venn.plot.df2)
df3 <- data.frame(G1=sample(1:100, 10), G2=sample(1:100, 10),
G3=sample(1:100, 10), G4=sample(1:100, 10))
venn.plot.df3 <- venn.diagram(x = as.list(df3), filename = NULL,
cat.col = c( "black", "red", "green3", "blue" ),
fill=c("black", "red", "green3", "blue"))
grid.draw(venn.plot.df3)
谢谢!
答案 0 :(得分:14)
venn.diagram
函数返回gList
个对象。似乎排列它们的方法是首先将它们转换为gTree
个对象,然后使用grid.arrange
函数进行绘图:
library(gridExtra)
grid.arrange(gTree(children=venn.plot.df1), gTree(children=venn.plot.df2),
gTree(children=venn.plot.df3), ncol=3)