calamari.plot.plot_family#

calamari.plot.plot_family(measurements, plot, *, ax=None, label_by='auto', labels=None, sort=True, cmap=None, offset=None, baseline=None, outliers='warn', outlier_threshold=None, **kwargs)#

Overlay one curve per measurement, labelled by each sweep’s fixed parameter.

The engine behind plot_chi_vs_h_family() and friends – use those aliases unless you are composing with your own plot function. Each measurement is drawn by one call to plot (any of the measurement-first helpers in this module) onto the same axes, with a legend label derived from the parameter that sweep held fixed: T = 5 K for a family of field sweeps, H = 3 T for a family of temperature sweeps, f = 997 Hz for label_by='frequency'.

The label is never a guess: the fixed value is the measured-row mean, and a sweep whose nominally-fixed parameter varies beyond calamari’s held-quantity tolerance is refused by name rather than mislabelled (pass labels= to name such curves yourself). Curves draw in ascending order of the fixed value, so legend, draw order and colours are monotonic in the physics.

Waterfalls. A family whose curves sit on top of one another – chi’(H) isotherms whose background drifts with temperature, say – hides the feature it was measured to show. baseline= subtracts a per-measurement baseline so the curves share a zero, and offset= then stacks them, curve i in draw order raised by i * offset. Both are display-only: no Measurement changes, and chi_series()/moment_series() still return the measured values. The y-label says so, gaining " (baseline-subtracted)" and/or " (offset for clarity)", so a shifted figure cannot pass for raw data. The tick values then describe the shifted curves; hiding them (ax.set_yticklabels([])) is the caller’s decision, per PL-1.

The shift is applied where each helper resolves its series, before anything is drawn, not by moving artists afterwards. Autoscaling (relim) does not account for artist transforms, so offset curves would fall outside the view limits. An error-bar container is several artists (line, caps, bar collection), and moving them consistently after the fact is fragile. Shifting the arrays first means the axes, the limits and ax.lines all agree on what is drawn. The price is that only this module’s helpers can take part: a foreign plot callable has no resolution step to shift, and is refused.

The baseline is computed per measurement from the resolved series, in the plotted unit (after units=, sample=, inverse=, imag_scale=). All the branches of one M(H) loop share one pooled baseline, and so do the frequency curves of a multi-frequency sweep, so their relative positions survive. With component='both', chi’ and chi’’ each get their own baseline. The offset is per measurement, so every curve of one sweep moves together. Error bars are the points’ own and are not changed: the baseline is treated as exact, and its own uncertainty is not propagated.

Bad points. One glitched reading is one wrong point on an ordinary plot, but a waterfall magnifies it: baseline='min' on a curve with one reading far below its neighbours subtracts that reading, and every clean point of the curve moves by the glitch’s depth – which can be several times the feature the figure exists to show. So each measurement is screened with Measurement.quality() before its curve is drawn, under the same outliers= contract as detect_transitions() and the maps: by default a flagged point is kept and named in one warning for the whole family. The warning, and the drop, cover only the points a curve draws: moment points for plot_mh()/plot_mt() and for a chi plot whose source resolves to DC M/H, chi’ points for an AC chi plot – so a glitch in the VSM rows of a combined VSM+AC file does not touch a chi’ figure. A foreign plot callable could draw any column, so there every flagged point counts. Screening happens on the Measurement before plot is called, so – unlike offset= and baseline= – it works with a foreign callable too. The return value stays the axes: the record of what was flagged is m.quality() itself, which lists every flagged point with its evidence.

Parameters:
  • measurements (Iterable[Any]) – One sweep per entry; paths are loaded with calamari.load.

  • plot (Callable[..., Axes]) – A measurement-first plot function from this module (plot_chi_vs_h(), plot_mh(), …). Called as plot(m, ax=ax, label=..., **kwargs).

  • ax (Axes | None) – Draw into these axes, or omit to create a figure.

  • label_by (str) – Which fixed parameter labels the curves. 'auto' reads each sweep’s scan_kind (an H-scan is labelled by its temperature, a T-scan by its field) and requires every sweep to agree; it never picks 'frequency', which must be asked for.

  • labels (Iterable[str] | None) – Explicit legend labels, one per measurement, used verbatim in the given order (label_by and sort are ignored) – the escape hatch for families distinguished by something other than T/H/f.

  • sort (bool) – Draw in ascending order of the fixed value. Default True.

  • cmap (Any | None) – Colour the curves sequentially by their fixed value (by position, when labels is given) instead of the property cycle – the readable choice for a family of many curves. Incompatible with an explicit color= in **kwargs.

  • offset (float | None) – Waterfall step in the plotted y unit. Curve i in draw order (ascending fixed value; the given order with labels= or sort=False) is raised by i * offset. A negative step stacks downwards. Default None (no offset).

  • baseline (str | float | tuple[float, float] | None) – Subtract one baseline per measurement before offsetting. 'start' is the value at the curve’s smallest x (the mean, if several points share it). 'min' is the curve’s minimum. A number x0 is the value linearly interpolated at x = x0, in the plotted x unit (K, Oe or T – a field family drawn with field_unit='tesla' takes x0 and windows in Tesla); it must lie on the curve. An (x_lo, x_hi) window is the mean of the points inside it (inclusive); it must contain at least one. Default None.

  • outliers (str | Sequence[QualityReport]) –

    What to do about points Measurement.quality() flags as glitches. 'warn' (default) draws them and warns once for the whole family, naming each point’s file, swept coordinate (in the plotted unit: field_unit='tesla' gives H in T), scored value and score – and, with baseline=, that a flagged point can set the baseline. 'drop' removes them before drawing, 'ignore' draws them without the warning and without screening at all (no quality() pass). A sequence of reports, one per measurement and aligned with the measurements in the order given (before any sorting), is an explicit drop of their flagged points – reports you have read, perhaps at your own threshold – and each is refused unless it describes its measurement as passed (same path, row labels it has, the same values at them), which catches a report taken before restrict() or on another isotherm of the same file. Dropping is never the default: removing a measured point changes the figure, and that is the caller’s call with the point in front of them.

    Each measurement is scored as passed – the whole view – so a point is judged against its neighbours in the file. Only flagged points the curve draws warn or are dropped (see Bad points above), and the drop is by row: a dropped chi’ row takes its chi’’ with it, and chi’’ – which quality() does not score – is screened only through chi’. When quality() cannot score a measurement (it reads columns no plot touches, such as the Min./Max. spreads, so an unrecognised unit there makes it raise), 'warn' draws the curve as measured and says it was not screened, while 'drop' raises, since the removal asked for cannot be honoured.

  • outlier_threshold (float | None) – Continuity score above which a point is flagged. None (default) means calamari.quality.CONTINUITY_THRESHOLD, the line detection and the maps use, so a point one warns about is the point the others warn about. Not accepted with reports, which carry their own.

  • **kwargs (Any) – Forwarded to every plot call (units=, sample=, source=, inverse=, field_unit=, style kwargs, …).

Return type:

Axes

Returns:

matplotlib.axes.Axes – The shared axes. Call ax.legend() to show the labels.

Warns:

UserWarning – With outliers='warn': once, when a drawn point is flagged; and once, when some measurement could not be screened.

Raises:
  • PlotInputError – For an empty family; a sweep whose fixed parameter is not actually fixed (named, with its span); sweeps whose scan_kind disagree under 'auto'; a family whose labels all come out identical (a mislabelled family – pick another label_by); a labels length mismatch; or cmap combined with color=. For offset=/baseline=: a malformed value, a plot callable that is not one of this module’s helpers, an x0 outside a curve, or a window containing none of a curve’s points. The last two are found as each curve is resolved, so curves drawn before it stay on the axes; the failing curve itself draws nothing. Also for a report count mismatch, a report that does not describe its measurement, or 'drop' on a measurement quality() cannot score; these are found before any curve is drawn.

  • calamari.exceptions.QualityInputError – Malformed outliers=/outlier_threshold= values, a single report instead of a sequence, invalid sequence entries, or reports combined with a threshold. Raised before drawing; also a ValueError.