Search code examples
rplotscalepartitioningvenn-diagram

Scale circle size Venn diagram by relative proportion


I am plotting a Venn diagram using the function draw.triple.venn() library(VennDiagram). This is my code in R:

    g = draw.triple.venn(
  area1 = 4.1, area2 = 5.6, area3 = 15.9, n12 = 1.3,n23 = 4.2, n13 = 2.3, n123 = 1.2, 
  category = c("Land use", "Environment", "Space"), lwd = c(1.2, 1.2, 1.2), lty = c(1, 1, 1),
  fill = c("darkgray", "gray", "lightgrey"), alpha = c(0.8, 0.8, 0.8), 
  cat.pos = c(330, 30, 150), cat.dist = c(0.06, 0.06, 0.05), sigdig=2, cex=2, cat.cex=2, 
  print.mode = c("raw", "percent"), cat.fontfamily = rep("serif", 3), margin = 0.01,
  ind = T)
  grid.arrange(gTree(children=g))
  grid::grid.text("Residual variance: 80.8%", x=0.18, y=0.03, gp=gpar(col="black", fontsize=16, fontfamily="serif", fontface=1))

This is the current figure:

enter image description here

My question, is it possible to scale the circle size by the relative proportion?

This is a link to the package https://cran.r-project.org/web/packages/VennDiagram/VennDiagram.pdf

Thank you very much for any advice.


Solution

  • Using library(eulerr)

    VennDiag <- euler(c("A" = 1.8, "B" = 1.5, "C" = 10.6, "A&B" = 0, "B&C" = 3.0, 
                        "A&C" = 1.1, "A&B&C" = 1.2))
    plot(VennDiag, counts = TRUE, font=1, cex=1, alpha=0.5,
         fill=c("grey", "lightgrey", "darkgrey"))
    

    enter image description here

    It comes with this error estimate:

    > VennDiag
          original fitted residuals region_error
    A          1.8  1.776     0.024        0.002
    B          1.5  1.471     0.029        0.002
    C         10.6 10.597     0.003        0.005
    A&B        0.0  0.210    -0.210        0.011
    A&C        1.1  1.158    -0.058        0.002
    B&C        3.0  3.024    -0.024        0.000
    A&B&C      1.2  1.145     0.055        0.003
    
    diag_error:  0.011 
    stress:      0