Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create venn diagram in python with 4 circles

How can I create a venn diagram in python from 4 sets? Seems like the limit in matplotlib is only 3?

from matplotlib_venn import venn3

v = venn3(
    [
        set(ether_list),
        set(bitcoin_list),
        set(doge_list),
    ],
)
like image 249
heyzi1992 Avatar asked Apr 25 '26 03:04

heyzi1992


2 Answers

Venn diagrams with circles can work only with <4 sets, because the geometrical properties of intersections (some won't be possible to show). Some python libraries that allow you to show venn diagrams with more exotic shapes are:

  • pyvenn
  • venn
like image 96
rikyeah Avatar answered Apr 27 '26 17:04

rikyeah


There is a new python 3 package venny4py that can create Venn diagrams with up to 4 sets. It can plot and save figure or plot it as a subplot of your own matplotlib figure, figure size and dpi adjustable.

Example:

pip install venny4py

from venny4py.venny4py import *

#dict of sets
sets = {
    'Set1': set(list("Harry Potter")),
    'Set2': set(list("Hermione Granger")),
    'Set3': set(list("Ron Weasley")),
    'Set4': set(list("Severus Snape"))}
    
venny4py(sets=sets)

Venn diagram with 4 sets

More details can be found here

like image 36
timanix Avatar answered Apr 27 '26 18:04

timanix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!