Matplotlib Venn

1.1.2 · active · verified Thu Apr 16

matplotlib-venn is a Python library that provides functions for plotting area-proportional two- and three-way Venn diagrams using Matplotlib. It enables visualization of set relationships with circles whose areas correspond to subset sizes. The current stable version is 1.1.2. The library sees active maintenance, with updates addressing functionality and dependencies, though not on a rapid fixed schedule.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to create both two-set and three-set Venn diagrams. The two-set diagram uses explicit subset counts, while the three-set diagram uses actual set objects for input. Both examples utilize `pyplot.show()` to display the generated diagrams.

from matplotlib_venn import venn2
from matplotlib import pyplot as plt

# Create a two-set Venn diagram with subset sizes
venn2(subsets=(3, 2, 1), set_labels=('Group A', 'Group B'))
plt.title("Basic Two-set Venn Diagram")
plt.show()

# Create a three-set Venn diagram from sets
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'))
plt.title("Three-set Venn Diagram from Data")
plt.show()

view raw JSON →