Domanda

I am trying to add a main and sub title to my venn diagram that I created using the following code in R. I have read through the R ‘VennDiagram’ package documentation without success. I've also tried using gird.arrange() with a textGrob and the graph from the resulting code, but received an error stating that all inputs must be 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
)
È stato utile?

Soluzione

The output of that function is a gList (and a side-effect of plotting, if you don't specify ind=FALSE). In order to use it with grid.arrange, you'd need to wrap it in a 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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top