Search code examples
rvenn-diagram

How to turn on the scaling in a triple Venn diagram?


I am trying to build the following diagram but while it must be possible (see the picture), I have an error about the negative area.

I also need my diagram scaled.

enter image description here

grid.newpage()                                        # Move to new plotting page
draw.triple.venn(area1 = 153,                          # Different color for each set
                 area2 = 173,
                 area3 = 224,
                 n12 = 2,
                 n23 = 26,
                 n13 = 8,
                 n123 = 140,
                 col = "red",
                 fill = c("pink", "green", "orange"), scaled = TRUE)

Solution

  • If you want the diagram to be scaled so that all the areas are (approximately) proportional to the number each contains, you should use the eulerr package instead. Note that in your example, the overlap between the three areas is so large that it is barely recognizable as a Venn Diagram any more:

    library(eulerr)
    
    plot(euler(c(
           "a" = 3, "b" = 5, "c" = 50,
           "a&b" = 2, "a&c" = 8, "b&c" = 26,
           "a&b&c" = 140
       )), quantities = TRUE,
       fills = scales::alpha(c("pink", "green", "orange"), 0.3))
    

    enter image description here