在一张图表上放置两个维恩图

时间:2018-05-28 17:13:44

标签: r charts r-grid venn-diagram

使用VennDiagram包我按以下方式生成两个图:

# 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

通过grid::grid.draw(vg1)grid::grid.draw(vg2)进行调用时,图表会按预期显示:

grid::grid.draw(vg1) vg1

grid::grid.draw(vg2) vg2

问题

如何创建一个网格对象,其中两个图都放在另一个下?

尝试

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

packGrob中的错误(grid.get(gPath),grob,side,row,row.before,   row.after,:无效'grob'

期望的结果

both graphs

1 个答案:

答案 0 :(得分:4)

一个解决方案可能是使用真棒multipanelfigure包(用基础填充面板,&#39;格&#39;,&#39; ggplot2&#39;&#39; ComplexHeatmap&# 39;绘图,凹凸和PNG,JPEG,SVG和TIFF图像)。

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

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

enter image description here