I am looking for a Python library that is able to produce a scaled, 4-set Venn diagrams. Scaled means that the displayed areas should try to match the cardinality of each set. 4-set means I should be able to specify 4 sets.

For example, the following Venn diagrams is based on 4 sets (I, II, III and IV), but is not scaled:

enter image description here

(it was generated using the R package VennDiagram with the code:

# http://www.inside-r.org/packages/cran/VennDiagram/docs/venn.diagram
# https://cran.r-project.org/web/packages/VennDiagram/VennDiagram.pdf
# http://www.biomedcentral.com/content/supplementary/1471-2105-12-35-s3.r
# http://www.biomedcentral.com/1471-2105/12/35

# Figure 1D
    x = list(
        I = c(1:60, 61:105, 106:140, 141:160, 166:175, 176:180, 181:205, 206:220),
        IV = c(531:605, 476:530, 336:375, 376:405, 181:205, 206:220, 166:175, 176:180),
        II = c(61:105, 106:140, 181:205, 206:220, 221:285, 286:335, 336:375, 376:405),
        III = c(406:475, 286:335, 106:140, 141:160, 166:175, 181:205, 336:375, 476:530)
    filename = "1D-quadruple_Venn.tiff",
    col = "black",
    lty = "dotted",
    lwd = 4,
    fill = c("cornflowerblue", "green", "yellow", "darkorchid1"),
    alpha = 0.50,
    label.col = c("orange", "white", "darkorchid4", "white", "white", "white", "white", "white", "darkblue", "white", "white", "white", "white", "darkgreen", "white"),
    cex = 2.5,
    fontfamily = "serif",
    fontface = "bold",
    cat.col = c("darkblue", "darkgreen", "orange", "darkorchid4"),
    cat.cex = 2.5,
    cat.fontfamily = "serif"

The Python package matplotlib-venn does scale but currently doesn't support more than 3 sets:

from matplotlib import pyplot as plt
from matplotlib_venn import venn3, venn3_circles
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])

venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))

enter image description here

Any language, OS and license is fine.

If possible:

  • the number of items in each set can displayed.
  • plots can be saved in some vectorial format.
  • plots can be displayed in black and white (for some antique publication requirements).

I am not fully sure to what extent the request is feasible, e.g. Chen, Hanbo, and Paul C. Boutros. "VennDiagram: a package for the generation of highly-customizable Venn and Euler diagrams in R." BMC bioinformatics 12.1 (2011): 35.:

During development of the VennDiagram package, it was discovered that it was impossible to draw accurate, scaled Venn diagrams with three sets using circles.


  • 2
    I think there was an error regarding matplotlib-venn. I fixed it, but you may wish to verify my correction. :) Oct 14, 2015 at 23:29
  • In Python, this may work but I couldn't install it yet github.com/tctianchi/pyvenn
    – Sos
    Apr 25, 2018 at 14:49
  • Note that the numbers in the graphics example provided do not match those shown in the R code. With the R code, the dark blue 992 would be a 60. Nov 9, 2018 at 23:40
  • github.com/tctianchi/pyvenn
    – Ben
    Dec 10, 2021 at 22:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.