heyzi1992
heyzi1992

Reputation: 113

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),
    ],
)

Upvotes: 10

Views: 20322

Answers (2)

timanix
timanix

Reputation: 142

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

Upvotes: 3

rikyeah
rikyeah

Reputation: 2013

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:

Upvotes: 9

Related Questions