nook.plotting.style¶
Visual language for the figures.
Two decisions drive everything here.
Type. These figures land beside LaTeX-set body text in NIM, PRC or the Nuclear Data Sheets, so they are set in Latin Modern with Computer Modern mathtext – the same faces as the surrounding prose. Matplotlib’s DejaVu default is the giveaway that a figure was made in a hurry.
Colour encodes parity. Positive and negative parity get their own hue, so a reader sees the parity structure of a band before reading a single label. That makes colour carry information rather than decorate; unassigned parity stays grey precisely so that missing data looks missing.
- class nook.plotting.style.Palette(ink='#14181F', paper='#FFFFFF', rule='#C9CDD3', positive='#A6321F', negative='#1F5673', unknown='#8A8F98', isomer='#C98A2B', wash='#F2F4F6')[source]¶
Bases:
objectNamed colours. Parity is the organising binary.
- nook.plotting.style.HALO = {'alpha': 0.82, 'boxstyle': 'round,pad=0.22', 'edgecolor': 'none', 'facecolor': '#FFFFFF'}¶
A soft background for labels that have to sit over a drawn line. Slightly translucent, so it reads as the label lifting off the artwork rather than as a hole punched through it.
- nook.plotting.style.figure_style(**overrides)[source]¶
Apply the package’s rcParams for the duration of a block.
- nook.plotting.style.jpi_label(spin_parity, max_alternatives=3)[source]¶
Render a
SpinParityas mathtext.Alternatives are joined with commas and a shared parity is factored out, the way an evaluator would write it:
1-,2-becomes(1,2)^-rather than repeating the superscript. Tentative assignments keep their parentheses because that distinction is physics, not styling.
- nook.plotting.style.half_life_label(half_life)[source]¶
Render a half-life compactly, picking a sensible unit.
- nook.plotting.style.dodge(values, min_gap, low=None, high=None)[source]¶
Nudge label positions apart while preserving their order.
Level schemes routinely put two states a few keV apart – 1607.97 and 1609.80 keV in the 180Lu decay – and their labels then overprint. This spreads a run of crowded labels just enough to separate them, keeping the block centred on where it started so the figure does not visibly drift. Callers draw a leader line wherever a label has moved.
- nook.plotting.style.separate_labels(fig, ax, texts, max_passes=40)[source]¶
Nudge overlapping labels apart, measuring in rendered pixels.
Placing labels by rule – dodge this column, stagger that one along its arrow – gets most of the way there and then fails on the awkward cases: an unusually wide spin assignment, a decay with only two levels, a Q-value that lands under the parent’s half-life. Rather than keep tuning offsets per figure, this measures what was actually drawn and moves the offenders.
Only vertical moves are made, so a label stays over the feature it annotates, and the halo covers whatever it crosses on the way. Returns the number of pairs still overlapping, which should be zero.