为Venn Diagram添加标题和子标题

时间:2014-01-18 10:30:43

标签: r venn-diagram

我正在尝试使用R中的以下代码为我创建的维恩图添加主要和子标题。我已经阅读了R'VennDiagram'包文档但没有成功。我也尝试使用带有textGrob的gird.arrange()和结果代码中的图形,但收到一条错误,指出所有输入必须是grobs。

require(VennDiagram)

draw.triple.venn(
  area1 = 396,
  area2 = 273,
  area3 = 147,
  n12 = 266,
  n23 = 86,
  n13 = 143,
  n123 = 83,
  category = c("Study", "Work", "Play"),
  fill = c("blue", "red", "green"),
  euler.d=TRUE,
  scaled=TRUE
)

1 个答案:

答案 0 :(得分:15)

该函数的输出是gList(如果未指定ind=FALSE,则为绘图的副作用)。为了将它与grid.arrange一起使用,您需要将其包装在gTree中,

g = draw.triple.venn(
  area1 = 396,
  area2 = 273,
  area3 = 147,
  n12 = 266,
  n23 = 86,
  n13 = 143,
  n123 = 83,
  category = c("Study", "Work", "Play"),
  fill = c("blue", "red", "green"),
  euler.d=TRUE,
  scaled=TRUE, ind = FALSE,
)

require(gridExtra)
grid.arrange(gTree(children=g), top="Title", bottom="subtitle")

theplot