0

I have five venndigram plots and I want put them in one slide. I wonder anyone could help me how to do it. I used the the following code but could not help me.

gridExtra::grid.arrange(grobs = list(VD1, VD2, VD3, VD4, VD5),
                        ncol = 3, nrow = 2, labels = LETTERS[1:5])

These were the errors

Error in gList(list(1, wrapvp = list(x = 0.5, y = 0.5, width = 1, height = 1,  : 
only 'grobs' allowed in "gList"
In addition: Warning messages:
 1: In grob$wrapvp <- vp : Coercing LHS to a list
 2: In grob$wrapvp <- vp : Coercing LHS to a list
 3: In grob$wrapvp <- vp : Coercing LHS to a list
 4: In grob$wrapvp <- vp : Coercing LHS to a list
 5: In grob$wrapvp <- vp : Coercing LHS to a list

Thank you!

Darren Tsai
  • 32,117
  • 5
  • 21
  • 51
adR
  • 305
  • 4
  • 14
  • How were the venndigrams created? You need to provide the package and function you use. – Darren Tsai Jul 21 '20 at 11:14
  • @Darren Tsai, Thank you. The package I used is ***VennDiagram*** and the function was ***venn.diagram*** – adR Jul 21 '20 at 13:09
  • Does this answer your question? [Venn diagrams in multiple figure](https://stackoverflow.com/questions/33269538/venn-diagrams-in-multiple-figure) – Darren Tsai Jul 21 '20 at 13:45

1 Answers1

1

You can use grid.arrange in combination with gTree like this:

library(VennDiagram)
#> Loading required package: grid
#> Loading required package: futile.logger
library(gridExtra)
set.seed(1)
list1 <- list(A=sample(LETTERS, 12), B=sample(LETTERS, 12))
venn1 <- venn.diagram(list1, filename = NULL)
set.seed(2)
list2 <- list(A=sample(LETTERS, 16), B=sample(LETTERS, 12))
venn2 <- venn.diagram(list2, filename = NULL)

venn3 <- venn.diagram(list(C=sample(LETTERS, 16), D=sample(LETTERS, 12)), filename = NULL)
venn4 <- venn.diagram(list(E=sample(LETTERS, 20), F=sample(LETTERS, 22)), filename = NULL)
venn5 <- venn.diagram(list(G=sample(LETTERS, 13), H=sample(LETTERS, 14)), filename = NULL)
grid.arrange(gTree(children=venn1),
             gTree(children=venn2),
             gTree(children=venn3),
             gTree(children=venn4),
             gTree(children=venn5),
             ncol=3)

Created on 2020-07-21 by the reprex package (v0.3.0)(https://reprex.tidyverse.org) (v0.3.0)

user12728748
  • 8,106
  • 2
  • 9
  • 14
  • Hi, @user12728748, Do you think this can be reproducible if I want to do the trivalent Venn diagram? I got something wired. It plots the three-circles for each case but couldn't show me the intersection region despite the presence of some overlapping values. One more thing, how I can label each as A,B,C.....? – adR Jul 30 '20 at 15:57
  • If you mean by trivalent a list of 3 vectors, it works the same way (e.g. `list(A=sample(LETTERS, 12), B=sample(LETTERS, 12), C=sample(LETTERS, 20))`). If by label you mean adding a title, just add `main="Venn A"` or something like that to the venn.diagram function... – user12728748 Jul 30 '20 at 17:08