To Draw Venn Diagram with matplotlib-venn you have to do pip install matplotlib-venn.
!pip install matplotlib-venn
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()
See /www.python-graph-gallery.com/venn-diagram/
Unicode Characters in Intersection and Union
# Unicode Character INTERSECTION ∩
print('\u2229')
# Unicode Character Union ∪
print('\u222A')
Draw Venn Diagram with matplotlib-venn with set_colors
from matplotlib_venn import venn3
# Create set objects: {}, set()
A = {2, 4, 6, 8, 10, 12}
B = {3, 6, 9, 12, 15, 18}
C = {5, 10, 15, 20, 25}
# Draw Venn Diagram with matplotlib-venn
v = venn3([A, B, C], set_labels = ('Set A', 'Set B', 'Set C'), set_colors=('gray', 'gray', 'gray'))
plt.show()
Custom the Venn Diagram
# Custom the Venn Diagram
v.get_patch_by_id('110').set_color('red')
plt.show()



Comments
Post a Comment