#170 Basic Venn diagram with 2 groups




There are 2 main methods to make a Venn diagram with the matplotlib library, leading to the same result.

The first consists to give directly the size of your group and their intersection. The second one consists to give 2 set of values, python will calculate itself the length of each set (=each group) and the number of common values (their intersection).








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

# First way to call the 2 group Venn diagram:
venn2(subsets = (10, 5, 2), set_labels = ('Group A', 'Group B'))

# Second way
venn2([set(['A', 'B', 'C', 'D']), set(['D', 'E', 'F'])])


Leave a Reply

Your email address will not be published.