rvenn-diagram

R - plot a Venn diagramm with proportions of overlap


I am trying to plot a Venn diagramm and I have the following specifications:


# size of g
g <- 97.22
# size of m
m <- 63.89

# overlaps
# i.e. the proportion of size m covered by g
g_covering_m <- 0.9015527
# i.e. the proportion of size g covered by m
m_covering_g <- 0.7253595



# the size of m covered by g
gm <- g_covering_m * m


# plotting
library(eulerr)
vennDiag <- euler(c("g" = g,
                    "m" = m, 
                    "g&m" = gm))
plot(vennDiag, counts = TRUE, 
    font=1, 
    cex=.1)
plot(vennDiag,
    edges = list(lty = 3),
    quantities = list(type = "counts", 
                      font = 3))

Obviously less than 0.9015527% (=g_covering_m) of the m circle is covered, because eulerr draws this by size.

Now I am wondering how I can get the circles to be drawn in a way, that it represents the specification that I have estimated? Thanks in advance!


Solution

  • It seems that by default the euler function expects numeric values indicating the disjointed set sizes (A∖B, A∩B, B∖A), not their total size (i.e., union, A, B, A∩B). But you can easily change that by supplying the corresponding option:

    # sizes
    g <- 97.22
    m <- 63.89
    
    # proportion of size coverages
    g_covering_m <- 0.9015527
    m_covering_g <- 0.7253595
    
    # the size of m covered by g
    gm <- g_covering_m * m
    
    # plotting
    library(eulerr)
    vennDiag <- euler(c("g" = g, "m" = m, "g&m" = gm), input="union")
    plot(vennDiag, edges = list(lty = 3),
         quantities = list(type = "counts", font = 3))
    

    result of above function with input type union