Eunoia for Python · python · 0.6.0
eunoia.venn
Source: python/eunoia/_venn.py
-> -> -> -> -> Lay out a (non-proportional) Venn diagram.
Unlike euler, every set intersection is always drawn, regardless of area. The arrangement is topological: the shapes come from the eunoia core's canonical Venn layouts, not from numerical optimization.
Parameters
sets:The sets to show. One of:
an
intn: n sets with default names"A","B", …;a sequence of set names, e.g.
["cat", "dog", "fish"];a mapping from set-combination labels (e.g.
"A","A&B") to per-region quantities, where the layout stays topological but the values are kept asoriginal_valuessoplot()can label each region (this is the common "Venn diagram with subset sizes" case);a mapping from set names to membership collections (
{"A": ["x", "y"], "B": ["y", "z"]}), counted into per-region quantities;a DataFrame (pandas, polars, … via narwhals) treated as a membership matrix; its column names are the sets and each row is counted into a region;
a numpy boolean array used as a membership matrix (2-D, or 1-D for a single set); set names come from
namesor are generated.
For
intand plain name-sequence input there are no quantities, sooriginal_valuesis empty.shape:"ellipse"(default),"circle","square","rectangle", or"rotated_rectangle". Ellipses support 1--5 sets; circles, squares, and rectangles 1--3; rotated rectangles 1--4 (the 4-set layout uses rotated rectangles to open all 15 regions). An unsupported set count raisesEunoiaError.complement:Optional universe area outside every set. For a Venn diagram this only adds a visual container box (the padded bounding box); it does not drive optimization.
input:How to read the supplied quantities.
"exclusive"(default): each value is a per-region count with no overlap included."inclusive": values are total set sizes that include overlaps. Only meaningful for the region-area mapping form; membership-list and DataFrame input are always exclusive (passing"inclusive"raisesEunoiaError).names:Set names for numpy-array input, one per column (or a single name for a 1-D array). Defaults to
"A","B", …. Only valid for array input; other forms carry their own names and passingnamesraises.ids:Per-observation member identifiers, retained as
membersand drawable withplot(members=True). Only valid for array and DataFrame input: a sequence with one entry per row, or, for a DataFrame, a column name to read identifiers from and exclude from the sets. Membership-list input carries its members intrinsically; passingidswith any other form raises.
Returns
VennFitA topological fit whose
plot()works likeEulerFit. When quantities were supplied they are kept inoriginal_valuesand shown byplot()automatically; otherwisefitted_valuesholds the geometric area of every region.