Plotting multiple Venndiagram (or diagrams) in single screen
[This article was first published on gacatag, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Here is an example of plotting 4 venn diagrams in a single screen with a 2*2 layout. Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
library(VennDiagram)
#defining vectors
av<- 1:10
bv<- 12:20
cv<- 7:15
# Building venndiagram grid objects (i.e. gList)
a<- venn.diagram(list(av= av, bv=bv), filename=NULL, main="VD1")
b<- venn.diagram(list(av=av, cv=cv), filename=NULL, main="VD2")
c<- venn.diagram(list(bv=bv, cv=cv), filename=NULL, main="VD3")
d<- venn.diagram(list(av=av, cv=cv), filename=NULL, main="VD4")
# Draw the diagrams
pushViewport(plotViewport(layout=grid.layout(2, 2)))
pushViewport(plotViewport(layout.pos.col=1, layout.pos.row=1))
grid.draw(a)
popViewport()
pushViewport(plotViewport(layout.pos.col=2, layout.pos.row=1))
grid.draw(b)
popViewport()
pushViewport(plotViewport(layout.pos.col=1, layout.pos.row=2))
grid.draw(c)
popViewport()
pushViewport(plotViewport(layout.pos.col=2, layout.pos.row=2))
grid.draw(d)
#defining vectors
av<- 1:10
bv<- 12:20
cv<- 7:15
# Building venndiagram grid objects (i.e. gList)
a<- venn.diagram(list(av= av, bv=bv), filename=NULL, main="VD1")
b<- venn.diagram(list(av=av, cv=cv), filename=NULL, main="VD2")
c<- venn.diagram(list(bv=bv, cv=cv), filename=NULL, main="VD3")
d<- venn.diagram(list(av=av, cv=cv), filename=NULL, main="VD4")
# Draw the diagrams
pushViewport(plotViewport(layout=grid.layout(2, 2)))
pushViewport(plotViewport(layout.pos.col=1, layout.pos.row=1))
grid.draw(a)
popViewport()
pushViewport(plotViewport(layout.pos.col=2, layout.pos.row=1))
grid.draw(b)
popViewport()
pushViewport(plotViewport(layout.pos.col=1, layout.pos.row=2))
grid.draw(c)
popViewport()
pushViewport(plotViewport(layout.pos.col=2, layout.pos.row=2))
grid.draw(d)
To leave a comment for the author, please follow the link and comment on their blog: gacatag.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.