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
The venn2
function of the matplotlib_venn
library is the best way to make a Venn Diagram with Python, as shown on the code below.
Note that several input formats are possible to get there. This first post of the section goes through them and should get you started from any kind of input. 🔥
# 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()
Venn 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:
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