Venn Diagram


A Venn Diagram (also called primary diagram, set diagram or logic diagram) is a diagram that shows all possible logical relationships between a finite collection of different sets. Fortunately, the matplotlib_venn library allows to build one easily with Python.

⏱ Quick start

# library
import matplotlib.pyplot as plt
from matplotlib_venn import venn2

# Use the venn2 function
venn2(subsets = (10, 5, 2), set_labels = ('Group A', 'Group B'))
plt.show()

Matplotlib logoVenn Diagram with Matplotlib and matplotlib-venn

Matplotlib is probably the most famous and flexible python library for data visualization. It is appropriate to build any kind of chart, including the lollipop plot thanks to its stem() function.

The Venn2() function allows to customize the venn diagram as much as you want, allowing to build some pretty neat figures as below:

The matplotlib-venn library allows a high level of customization. Here is an example taking advantage of it

The matplotlib-venn library allows a high level of customization. Here is an example taking advantage of it

Upset plot as an alternative

Venn diagrams are great to visualize the intersection between 2 or 3 sets. Above that they become quite messy and unreadable.

There is a alternative to them: the upSet plot that can be made thanks to the upSetPlot library

Contact


👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥