calamari.plot.overlay_transitions#

calamari.plot.overlay_transitions(transitions, *, ax, grid=None, family_scale='linear', x=None, field_unit=None, marker_by='method', color_by=None, markers=None, colors=None, connect=None, show_errors=True, legend=True, scatter_kwargs=None)#

Draw transition candidates onto existing axes.

For a standalone physical T-H diagram use plot_transitions().

Two modes, chosen by grid:

  • 1-D sweep overlay (grid=None): vertical rules at each candidate’s swept coordinate on a sweep plot (plot_mt(), plot_chi_vs_t(), …) – the audit view: the marks on the curve that produced them. x='temperature'/'field' restricts to rows swept along that axis (default: every row, each on its own axis value). A field rule sits at H_T, which is in Tesla, so it has to be scaled into the unit the sweep was plotted in (the field_unit= given to plot_chi_vs_h()/ plot_mh()) – and the two choices put it a factor of 10^4 apart. field_unit=None (the default) reads that unit from the axes’ x-label when it is calamari’s own (Field (Oe) or the mu0 H (T) label): the plotting call wrote it from the same field_unit, so it is a record, not a guess. Any other label – one you have replaced, or none – names no unit calamari can trust, so the default then refuses, naming the fix, rather than assume Oe and put a Tesla sweep’s rule at 10^4 times its field. That refusal comes only when a field rule would actually be drawn: T-swept rules need no unit, so a chi(T) or M(T) overlay works on any label. An explicit 'oe' or 'tesla' is taken at its word on a label you have replaced, but must agree with calamari’s own label where there is one; a contradiction is refused with the fix. Every refusal comes before anything is drawn.

  • T-H map overlay (grid= the map’s PlotGrid): points at (T, H) over draw_map() output. The grid is REQUIRED here because the axes alone cannot reveal a family_scale='index' rendering, where physical coordinates would land on wrong rows – the silently-wrong-points failure this parameter exists to prevent. The map’s field axis is always mu0 H in Tesla, so field_unit has nothing to choose here: the default and 'tesla' (simply true – one field_unit='tesla' can serve every overlay in a script) are accepted and change nothing, and 'oe' is refused, since no map axis is in Oe. Pass the same family_scale the map was drawn with; in 'index' mode points snap to family rows by the same insertion-index rule (searchsorted) as the map’s own sample overlay, so a candidate and the sample it came from land on the same row. The one-call forms (plot_chi_map(..., transitions=...)) wire both through automatically.

Encoding is generic column mapping: marker_by/color_by name candidate columns (method, signal, swept_axis, probe, …); method markers come from the calamari.transitions.METHODS registry so the same criterion has the same shape on every figure. The combined legend shows one entry per observed (marker, colour) pair, and its title carries the encoding rule plus – when the input is a .robust()-filtered result – the thresholds applied, so the figure states its own inclusion criterion. A bare DataFrame (e.g. result.candidates after a pandas filter) carries no thresholds; prefer filtering with .robust().

When the color_by column has more distinct values than the palette has colours (_MAX_LEGEND_COLOR_VALUES), the colours still cycle but the per-value legend entries are dropped: past that point the cycle repeats, so the legend would be both unreadably long and actively wrong. color_by='chain_id' is the case this exists for.

connect= names a column – 'chain_id' from link() is the intended one – whose equal values are joined by a thin line in family order, one line per value with two or more members. That is the visible form of the cross-sweep argument: a boundary that recurs traces a curve across the map, while unlinked noise stays a scatter of dots. The line takes its colour from color_by when that is set (the first member’s, since a chain’s members normally share the value being encoded) and a neutral grey otherwise, sits below the markers, and never enters the legend. Drawing the line is map-only: on a 1-D overlay the candidates are vertical rules on ONE sweep, where a line joining other sweeps’ candidates would have nothing to run along, so no line is drawn there. The column name is still checked in both modes – naming a column the frame does not carry is a caller error either way, and its usual cause is a result that was never linked, which accepting the argument in silence would hide.

Error bars (show_errors=True) draw the detected-axis standard errors (T_err_K/H_err_T); the fixed-axis spans are provenance, not uncertainties, and are never drawn as bars.

Return type:

dict

Returns:

dict – (marker value, colour value) -> list of matplotlib artists – the handles for a custom legend or removal. Error-bar containers are included (they are not PathCollections). connect= adds ('connect', <column value>) keys for the chain lines, so they can be restyled or removed independently of the markers.