Eunoia for Python · python · 0.6.0
eunoia.EulerFit
Source: python/eunoia/_models.py
Bases: typing.Generic[S]
Result of fitting an area-proportional Euler diagram.
Attributes
shapes:Tuple of fitted shapes (one per input set), in the order the sets were first encountered in the input.
original_values:The values originally passed in. Keys are canonical (sorted) form.
fitted_values:The fitted areas, expressed in the same scale as
original_values(exclusive or inclusive, depending oninput).residuals:original_values - fitted_valuesper region.region_error:Per-region error (eunoia core's region_error metric, always in per-region exclusive form).
diag_error:Maximum region error (eulerAPE-style worst-case metric).
stress:venneuler-style stress metric.
loss:Final value of the objective the optimizer minimized.
container:The fitted universe box, when the diagram was fit with
complement; otherwiseNone.members:For membership-list input, or array/DataFrame input with
ids=, a mapping from canonical region key to the sorted member names in that region;Nonefor area/int input that carries no identities. Enablesplot(members=True).
shapes
Source: python/eunoia/_models.py
: original_values
Source: python/eunoia/_models.py
: fitted_values
Source: python/eunoia/_models.py
: residuals
Source: python/eunoia/_models.py
: region_error
Source: python/eunoia/_models.py
: diag_error
Source: python/eunoia/_models.py
: stress
Source: python/eunoia/_models.py
: loss
Source: python/eunoia/_models.py
: container
Source: python/eunoia/_models.py
: | None = Nonemembers
Source: python/eunoia/_models.py
: | None = plot_data
Source: python/eunoia/_models.py
: = plot
Source: python/eunoia/_models.py
-> Render the fitted diagram with matplotlib.
Parameters
ax:Existing matplotlib Axes to draw into. If
None, a new figure and axes are created viaplt.subplots().colors:Per-set colors. Either a sequence of colors (one per set, in shape order) or a dict mapping set name to color.
Noneuses thepaletteglobal option (matplotlib'stab10by default; seeeunoia.options).fills:Per-region fill style overrides. Maps canonical region key to a dict of
PathPatchkeyword arguments.edges:Edge (set boundary) style overrides, as
PathPatchkeyword arguments. A flat dict is applied uniformly to every set outline; a dict keyed by set name (with kwargs dicts as values) styles each set independently (sets absent from the dict are left at their defaults); a sequence of kwargs dicts assigns one style per set in shape order.labels:Set name labels at each set's anchor.
None(default) shows them when there is no legend and hides them when a legend is drawn;TrueorFalseforce them on or off. A dict turns labels on and customizes text and style: either a per-set mapping (keys are set names) whose values are a replacement string, anax.textkwargs dict (with an optional"text"key for custom text such as mathtextr"$lpha$"), orNoneorFalseto hide that set; or a uniformax.textkwargs dict (no key a set name) applied to every label, e.g.{"fontsize": 14}. Three reserved keys control placement rather than text style:set_positionis"inside"(default) or"outside";set_placementconfigures exterior set names withmargin,angular_steps, andprecision; andplacementselects the fallback for region blocks—"raycast","force_directed","matched", or"elbow"—or a dict withstrategy,margin,iterations,min_gap,precision,tether,leader_gap, andleader.quantities:Show per-region values.
None(default) shows nothing for anEulerFit; for aVennFitit shows the supplied values when the diagram was built with quantities, and nothing otherwise.Falsealways shows nothing;Trueshows the input values as raw counts. A string selects either the value source ("original", the input values, the default; or"fitted", the fitted areas) or the display type ("counts", raw values; or"percent", each region's share of the total). A dict combines both and adds text styling: ``{"source": "fitted", "type": ["counts", "percent"], "color": "dimgray", "fontsize": 8}.type`` may name both"counts"and"percent"to stack the count above the percentage; any other keys are forwarded toax.text.members:Show each region's member names (available only when the fit carries
members, i.e. membership-list input, or array/DataFrame input withids=; requesting them otherwise raises).None(default) orFalseshows nothing;Truelists every member. A dict adds options and text styling:maxcaps how many names are listed per region, replacing the rest with a"+N more"line, and any other keys are forwarded toax.text(e.g.color,fontsize). Long member lists that do not fit inside a region are placed outside with a leader line; usemaxto keep blocks compact. Setmode="packed"in the dict to pack each name individually inside its region. Packed mode also acceptsarrangement,scale,min_scale,gap,seed,precision, andmax_attempts.glyphs:Draw one equal-sized dot per requested exclusive unit.
False(default) disables glyphs;Trueuses automatic sizing and a uniform arrangement. A dict acceptsarrangement("uniform"or"random"),radius,gap,seed,precision, andmax_attempts, plus circle style overrides. Quantities must be finite, nonnegative integers; they are never rounded silently.legend:Draw a legend mapping each set to a color swatch, useful when in-diagram labels overlap.
Trueuses matplotlib defaults; a dict is forwarded toax.legend()(e.g.loc,title,ncol,bbox_to_anchor). When set,labelsdefaults off.complement:Style overrides (
Rectanglepatch kwargs) for the universe container box, drawn only when the fit has acontainer. Ignored otherwise.
Returns
matplotlib.axes.AxesThe axes the diagram was drawn into.
plot_plotly
Source: python/eunoia/_models.py
-> Render the fitted diagram to an interactive plotly figure.
The interactive counterpart to plot, requiring the optional eunoia[plotly] extra (pip install 'eunoia[plotly]'). It draws the same area-proportional geometry and size-aware labels, but as a plotly.graph_objects.Figure with per-region hover tooltips -- useful for dense multi-set diagrams where member names do not fit inside small regions.
Most parameters mirror plot (colors, fills, edges, labels, quantities, members, glyphs, legend, and complement); style dicts are read as the analogous plotly properties (the honored keys are colors, alpha, linewidth, and fontsize). The plotly-only parameters are:
Parameters
width:Figure width in pixels (default 700). The height defaults to whatever preserves the diagram's aspect ratio.
height:Figure height in pixels.
None(default) derives it fromwidthand the diagram's aspect ratio.hover:Per-region hover tooltips.
True(default) shows each region's key, its count, and -- when the fit carriesmembers-- its member names;"members"or"quantities"restrict the tooltip to one of those;Falsedisables hover.
Returns
plotly.graph_objects.FigureThe interactive figure.