Venn Plot
Venn and Euler diagrams from pre-aggregated subset sizes.
Only 2- or 3-set diagrams are supported; input is subset sizes (no aggregation is performed). vary_size=True switches from equal circles to area-accurate regions.
plot(df, labels, title=None, eyebrow=None, subtitle=None, source_text=None, vary_size=False, figsize=None, ax=None, subset_label_formatter=None, **kwargs)
Plot a Venn or Euler diagram from the subset sizes in a DataFrame.
df needs groups, a tuple (not a list) of 0/1 flags where flag i means membership of
labels[i], and percent, the subset size, shown as given. The all-zero subset is
dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Frame with |
required |
labels
|
list[str]
|
Labels for the sets (2 or 3). |
required |
title
|
str
|
Plot title. |
None
|
eyebrow
|
str
|
Uppercase label rendered above the title. |
None
|
subtitle
|
str
|
Supporting copy rendered below the title. |
None
|
source_text
|
str
|
Source attribution rendered at the bottom. |
None
|
vary_size
|
bool
|
False draws equal circles; True sizes each region by its subset size. |
False
|
figsize
|
tuple[int, int]
|
Figure size, used only when ax is None. |
None
|
ax
|
Axes
|
Axes to plot on. |
None
|
subset_label_formatter
|
callable
|
Applied to each subset size; if None, the raw value is stringified. |
None
|
**kwargs
|
Any
|
Forwarded to matplotlib_set_diagrams' |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
SubplotBase |
SubplotBase
|
The matplotlib axes object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of sets (len(labels)) is not 2 or 3. |
Source code in openretailscience/plots/venn.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |