将两个维恩图放在一张图表上
Placing two venn diagrams on one chart
使用 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)
grid::grid.draw(vg2)
问题
如何创建一个网格对象,其中两个图一个接一个地放置?
尝试
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'
想要的结果
一个解决方案可能是使用很棒的 multipanelfigure
包(用基础填充面板,'lattice','ggplot2' 和 'ComplexHeatmap' 图,grobs和 PNG、JPEG、SVG 和 TIFF 图像)。
library(multipanelfigure)
figure <- multi_panel_figure(columns = 1, rows = 2)
figure %<>%
fill_panel(vg1) %<>%
fill_panel(vg2)
使用 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)
grid::grid.draw(vg2)
问题
如何创建一个网格对象,其中两个图一个接一个地放置?
尝试
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'
想要的结果
一个解决方案可能是使用很棒的 multipanelfigure
包(用基础填充面板,'lattice','ggplot2' 和 'ComplexHeatmap' 图,grobs和 PNG、JPEG、SVG 和 TIFF 图像)。
library(multipanelfigure)
figure <- multi_panel_figure(columns = 1, rows = 2)
figure %<>%
fill_panel(vg1) %<>%
fill_panel(vg2)