Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding title and sub title to Venn Diagram

Tags:

r

venn-diagram

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
)
like image 340
user3209543 Avatar asked Jan 18 '14 10:01

user3209543


1 Answers

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

like image 195
baptiste Avatar answered Sep 19 '22 15:09

baptiste