Search code examples
rvenn-diagramjupyter-irkernel

Adding a Sample Space to a Venn Diagram in R


I am trying to insert of a simple Venn diagram in an jupyter notebook on R. I have been able to generate a simple 2-set diagram using the VennDiagram library. However I can't seem to figure out how to work the triple diagram in way that yields 2 intersecting sets that are in a subset of another larger set.

Maybe I'm using the wrong library?

Edit:

This is for an illustration, I just need to draw an example of a Venn Diagram. The data would be something like:

S=(1,2,3)

A=(1,2)

B=(2,3)


Solution

  • The latest development version of my r package eulerr is now able to take a list of sample spaces as input. It, however, produces euler diagrams (proportional Venn diagrams) (which is why your specifications won't result in two diagrams intersecting within another).

    # devtoools::install_github("jolars/eulerr")
    
    library(eulerr)
    
    ll <- list(S = c(1, 2, 3), A = c(1, 2), B = c(2, 3))
    
    fit <- euler(ll)
    
    plot(fit)
    

    euler diagram 1

    If you want two intersecting circles within a third, try the following:

    plot(euler(c(S = 5, "A&B&S" = 3, "A&S" = 1, "B&S" = 1)))
    

    intersecting euler diagram