dit.visualization

Visualizations of multivariate distributions.

This subpackage collects plotting tools for exploring the structure of joint distributions. Currently it provides an UpSet-style plot of the atoms of a distribution’s information diagram, which scales to an arbitrary number of random variables (unlike Venn/Euler diagrams).

Classes

InformationUpsetPlot

An UpSet plot of the atoms of a distribution's information diagram.

Reference

class InformationUpsetPlot(dist, *, partition=<class 'dit.profiles.information_partitions.ShannonPartition'>)[source]

Bases: object

An UpSet plot of the atoms of a distribution’s information diagram.

The plot has three coordinated panels:

  • a matrix whose rows are random variables and whose columns are the atoms of the information diagram; a filled dot means the variable participates in that atom (an unconditioned variable), an empty dot means it is conditioned upon;

  • an atom bar chart (above the matrix) giving each atom’s value, colored by sign since information atoms may be negative;

  • a variable bar chart (beside the matrix) giving each variable’s marginal entropy H[X_i].

dist

The distribution being visualized.

Type:

Distribution

partition

The information partition supplying the atoms.

Type:

BaseInformationPartition

variables

The random variables, in display order.

Type:

list

atoms

One entry per atom, each with keys members (frozenset of the participating variables), conditions (frozenset of the conditioned variables), degree (number of members) and value.

Type:

list of dict

sizes

Mapping of variable to its marginal entropy H[X_i].

Type:

dict

unit

The unit the atom/size values are reported in (e.g. "bits").

Type:

str

draw(ax=None, *, sort_by='value', min_degree=1, show_values=True, color_positive='C0', color_negative='C3')[source]

Draw the UpSet plot using matplotlib.

Parameters:
  • ax (Axis or None) – An existing matplotlib axis whose location is used to host the panels. If None, a new figure is created.

  • sort_by (str) – How to order the atom columns; see _sorted_atoms().

  • min_degree (int) – Only draw atoms of at least this degree.

  • show_values (bool) – Annotate each atom bar with its value.

  • color_positive (color) – The color for non-negative atoms.

  • color_negative (color) – The color for negative atoms.

Returns:

axes – A dictionary with keys "atoms", "matrix", and "sizes" mapping to the three panel axes.

Return type:

dict

to_string(digits=3)[source]

Render the underlying partition as a table.

Parameters:

digits (int) – The number of digits to display.