Skip to content

synaptome.plot

synaptome.plot

Plots of values and results, reached through study.plot (DESIGN.md section 10). Data views (by variable name) are in step 14a; result views in 14b. set_style / style set the font size and palette of every figure.

PlotAccessor

study.plot: one method per view, each returning a Plot (see the module docstring).

box(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center=None, interval=None, confidence=0.95, points=True, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, seed=0, ax=None, rotate_ticks='auto', box_kws=None, points_kws=None, center_kws=None, interval_kws=None)

Box plot of variable per x level: median, quartiles and 1.5 IQR whiskers, with the values on top (points=False hides them and draws the outliers). center / interval add a marker with an error bar, e.g. center="mean", interval="ci". See the module docstring for the common arguments.

Returns:

Type Description
Plot

data: one row per group (and hue): n, center, low, high, the box statistics (median, q1, q3, whislo, whishi) and position.

violin(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center='median', interval='iqr', confidence=0.95, points=False, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, seed=0, ax=None, rotate_ticks='auto', violin_kws=None, points_kws=None, center_kws=None, interval_kws=None)

Violin plot of variable per x level, with the median and IQR inside by default. Pooled values (e.g. every source of every subject) make one violin per group. Same arguments as box.

bar(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center='mean', interval='ci', confidence=0.95, points=False, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, seed=0, ax=None, rotate_ticks='auto', bar_kws=None, points_kws=None, interval_kws=None)

Bar chart: the bar is center (default mean), the error bar interval (default 95% CI).

point(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center='mean', interval='ci', confidence=0.95, points=False, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, seed=0, ax=None, rotate_ticks='auto', points_kws=None, center_kws=None, interval_kws=None)

A marker at center (default mean) with an interval error bar (default 95% CI) per group.

strip(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center='median', interval=None, confidence=0.95, labels=None, palette=None, xlabel=None, ylabel=None, title=None, legend=None, seed=0, ax=None, rotate_ticks='auto', points_kws=None, center_kws=None, interval_kws=None)

Every value as a jittered point per group, with a line at center (default median).

line(variable, x, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', order=None, hue_order=None, center='mean', interval='ci', confidence=0.95, interval_style='band', smooth=None, raw=None, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, line_kws=None, interval_kws=None, raw_kws=None)

center of variable against coordinate x, one line per hue level, with interval as a band (interval_style="bars" for error bars). Default: mean and 95% CI, across unit when given.

Technical details

A numeric x is drawn at its values; any other as evenly spaced categories. smooth (numeric x only) is for display: a centered moving average smooth wide in x units of the center and of each interval bound, applied after the summary; the unsmoothed center is drawn faintly underneath (raw=False hides it), and Plot.data keeps both.

Returns:

Type Description
Plot

data: one row per hue level and x: n, center, low, high (and *_smooth).

scatter(variable, x, hue=None, *, pair=None, identity=False, subset=None, reduce=None, unit=None, unit_reduce='mean', hue_order=None, labels=None, palette=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, points_kws=None, line_kws=None)

Every value of variable against coordinate x, one colour per hue level. With pair=(a, b), x is a factor and each point is one unit (and remaining coordinate): its value at x=a horizontally, at x=b vertically, e.g. a method against the reference. identity=True adds the y = x line and equal axes.

Returns:

Type Description
Plot

points: the values drawn (with pair: columns a and b, matched).

distribution(variable, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', hue_order=None, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, line_kws=None, fill_kws=None)

Kernel density of variable (x-axis), one filled curve per hue level, each normalized on its own so shapes compare whatever the group sizes.

histogram(variable, hue=None, *, subset=None, reduce=None, unit=None, unit_reduce='mean', hue_order=None, labels=None, palette=None, fill_alpha=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, hist_kws=None)

Histogram of variable, one translucent layer per hue level on shared bins (hist_kws={"bins": ...}, default "auto").

ecdf(variable, hue=None, *, per_unit=None, subset=None, reduce=None, unit=None, unit_reduce='mean', hue_order=None, labels=None, palette=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, line_kws=None, unit_kws=None)

Empirical cumulative distribution of variable: for each value, the share of values at or below it, one curve per hue level. It shows, e.g., for which share of sources a method's error is below the baseline's. per_unit="subject" draws one faint curve per subject and, bold, the median of the subjects' curves (each subject counts once, whatever its number of values).

Returns:

Type Description
Plot

data: the curves drawn (x, share, and hue and curve: "pooled", "median" or a unit).

agreement(variable, by, reference, *, competitor=None, subset=None, reduce=None, unit=None, unit_reduce='mean', limits=1.96, labels=None, palette=None, xlabel=None, ylabel=None, title=None, legend=None, ax=None, points_kws=None, line_kws=None)

Bland-Altman agreement of each level of by with reference: one point per matched pair (unit and remaining coordinates), the mean of the two values horizontally, their difference (competitor - reference) vertically; a solid line at the bias (mean difference) and dashed lines at the limits of agreement, bias -/+ limits * SD (95% by default). competitor= keeps one level.

Returns:

Type Description
Plot

data: one row per competitor: n, bias, sd, low, high. points: the pairs with mean and difference.

comparison(result, kind='auto', reference=None, **kwargs)

A test result as its groups, with brackets on significant pairs (results.comparison).

differences(result, reference=None, **kwargs)

The per-unit differences, draws or difference curves behind a test (results.differences).

along(result, **kwargs)

A cluster test as curves with its significant clusters (synaptome.plot.results.along).

estimate(results_, effect_size=None, **kwargs)

Estimates with their intervals; a forest for pairs or several results (results.estimate).

normality(result, kind='distribution', **kwargs)

A normality test as densities, histograms or Q-Q plots (synaptome.plot.results.normality).

omnibus(result, kind='box', **kwargs)

An omnibus test as all its groups, with its verdict (synaptome.plot.results.omnibus).

Plot

A drawn figure, with the numbers it shows.

Unpacks as fig, ax = study.plot.box(...).

Attributes:

Name Type Description
ax Axes
fig Figure
kind str

Which view this is ("box", "ecdf", ...).

data DataFrame | None

The summary drawn: e.g. one row per group with n, center, low, high (and the box statistics on a box plot). data.attrs records center, interval, confidence and what was pooled.

points DataFrame | None

The values drawn (after subset, reduce and the unit collapse).

artists dict

Matplotlib artists by layer ("boxes", "points", "centers", "intervals", "lines", ...), to restyle after the fact.

fig property

The figure holding the axes.

colors(levels, all_levels=None, palette=None)

{level: colour} for the levels drawn. The colour of a level is its position among all_levels (every level of the variable in the study), not among those drawn, so it stays the same from one figure to the next, whatever subset is plotted.

Parameters:

Name Type Description Default
levels Sequence

The levels drawn.

required
all_levels Sequence | None

Every level, in their stable order; default: levels.

None
palette Any

Default: the style's palette (set_style), else the active colour cycle.

None

set_style(fontsize=None, palette=None)

Sets the style of every later figure.

Parameters:

Name Type Description Default
fontsize float | None

One size for labels, ticks, titles, legends and annotations; None keeps matplotlib's rcParams.

None
palette Any

Default colours: {level: colour}, a list (cycled), or a matplotlib colormap name; None uses the active axes.prop_cycle, so plt.style.use(...) themes apply.

None