# eunoia.venn

Python · 0.6.0

[Source](<https://github.com/jolars/eunoia-py/blob/af16491d64a6d1f3b87b8645bd9697593daa0f02/python/eunoia/_venn.py>)

<a id="overload-d2554e96385dc978df4770d96c2c1b82018c1a056ae62034986e1777b46027c4"></a>

```python
venn(
    sets: VennInput,
    *,
    shape: typing.Literal["ellipse"] = ...,
    complement: float | None = ...,
    input: typing.Literal["exclusive", "inclusive"] = ...,
    names: Sequence[str] | None = ...,
    ids: str | Sequence[object] | None = ...
) -> eunoia.VennFit[eunoia.Ellipse]
```

<a id="overload-3a3c0617a791bb9dc2589ca5a06658ad32e03703edc635caf56986e5e3b8f363"></a>

```python
venn(
    sets: VennInput,
    *,
    shape: typing.Literal["circle"],
    complement: float | None = ...,
    input: typing.Literal["exclusive", "inclusive"] = ...,
    names: Sequence[str] | None = ...,
    ids: str | Sequence[object] | None = ...
) -> eunoia.VennFit[eunoia.Circle]
```

<a id="overload-ec32dbb6402e4cd20b2f784ddbaeea0ace977592a39c76f7fa51639e130ef38a"></a>

```python
venn(
    sets: VennInput,
    *,
    shape: typing.Literal["square"],
    complement: float | None = ...,
    input: typing.Literal["exclusive", "inclusive"] = ...,
    names: Sequence[str] | None = ...,
    ids: str | Sequence[object] | None = ...
) -> eunoia.VennFit[eunoia.Square]
```

<a id="overload-02252078608aeed48ce7bd71431d0b907e9dfa545624b171270a81c623334ee3"></a>

```python
venn(
    sets: VennInput,
    *,
    shape: typing.Literal["rectangle"],
    complement: float | None = ...,
    input: typing.Literal["exclusive", "inclusive"] = ...,
    names: Sequence[str] | None = ...,
    ids: str | Sequence[object] | None = ...
) -> eunoia.VennFit[eunoia.Rectangle]
```

<a id="overload-2213c706c263238e8ede739b95f0e696473730a2545ed619f6166cab9c3eaeea"></a>

```python
venn(
    sets: VennInput,
    *,
    shape: typing.Literal["rotated_rectangle"],
    complement: float | None = ...,
    input: typing.Literal["exclusive", "inclusive"] = ...,
    names: Sequence[str] | None = ...,
    ids: str | Sequence[object] | None = ...
) -> eunoia.VennFit[eunoia.RotatedRectangle]
```

Lay out a (non-proportional) Venn diagram.

Unlike [`euler`](<8291fbac4859d2666a285086e662f92046f7942a91545da3ed0ecae6abfdafcf>), 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.

<a id="parameters"></a>

## Parameters

`sets:`

The sets to show. One of:

- an `int` *n*: *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 as [`original_values`](<368c6eef5f44d1af6db73a3b8b4a2c7058500ce15acc586ff7b67311c0627c97#original_values>) so `plot()` 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 `names` or are generated.

For `int` and plain name-sequence input there are no quantities, so `original_values` is 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 raises [`EunoiaError`](<fc5375cf55defbd19695ed3bcd389fd2ab533221213ce5ef07233c80c90a35c0>).

`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"` raises [`EunoiaError`](<fc5375cf55defbd19695ed3bcd389fd2ab533221213ce5ef07233c80c90a35c0>)).

`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 passing `names` raises.

`ids:`

Per-observation member identifiers, retained as [`members`](<368c6eef5f44d1af6db73a3b8b4a2c7058500ce15acc586ff7b67311c0627c97#members>) and drawable with `plot(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; passing `ids` with any other form raises.

<a id="returns"></a>

## Returns

`VennFit`

A topological fit whose `plot()` works like [`EulerFit`](<368c6eef5f44d1af6db73a3b8b4a2c7058500ce15acc586ff7b67311c0627c97>). When quantities were supplied they are kept in `original_values` and shown by `plot()` automatically; otherwise `fitted_values` holds the geometric area of every region.
