Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing two venn diagrams on one chart

Tags:

Using VennDiagram package I'm generating two graphs in the following manner:

# First graph
VennDiagram::draw.pairwise.venn(
    area1 = 100,
    area2 = 70,
    cross.area = 30,
    category = c("A1", "B1"),
    fill = c("#00204DFF", "#FFEA46FF")
) -> vg1

# Second graph
VennDiagram::draw.pairwise.venn(
    area1 = 120,
    area2 = 80,
    cross.area = 10,
    category = c("A2", "B2"),
    fill = c("#000004FF", "#FCFFA4FF")
) -> vg2

When called via grid::grid.draw(vg1) and grid::grid.draw(vg2) the charts show as expected:

grid::grid.draw(vg1) vg1

grid::grid.draw(vg2) vg2

Question

How can I create one grid object where both plots are placed one under another?

Attempt

grdFrme <- grid::grid.frame(name = "gf")
grid::grid.pack("gf", vg1)

Error in packGrob(grid.get(gPath), grob, side, row, row.before, row.after, : invalid 'grob'

Desired results

both graphs

like image 481
Konrad Avatar asked May 28 '18 17:05

Konrad


People also ask

How do you create a stacked Venn diagram in Excel?

On the Insert tab, in the Illustrations group, click SmartArt. In the Choose a SmartArt Graphic gallery, click Relationship, click a Venn diagram layout (such as Basic Venn), and then click OK.

What is an overlapping chart called?

Venn diagrams are charts with overlapping circles that indicate how much different groups have in common. Charts supports Venn diagrams with two or three circles.

What is a stacked Venn diagram?

3. The third type is Stacked Venn. This is used to show overlapping relationships and is considered a good choice for emphasizing growth or gradation of an organization or business.


1 Answers

One solution could be to use awesome multipanelfigure package (fill the panels with base, 'lattice', 'ggplot2' and 'ComplexHeatmap' plots, grobs, and PNG, JPEG, SVG and TIFF images).

library(multipanelfigure)
figure <- multi_panel_figure(columns = 1, rows = 2)

figure %<>% 
    fill_panel(vg1) %<>%
    fill_panel(vg2)

enter image description here

like image 187
pogibas Avatar answered Sep 28 '22 18:09

pogibas