Skip to content

[FIX] Report layout polish — title helper, trajectory y-labels, clock legend, rose whitespace - #84

Merged
eleanorfrajka merged 4 commits into
mainfrom
rep/09-layout-polish
Aug 19, 2026
Merged

[FIX] Report layout polish — title helper, trajectory y-labels, clock legend, rose whitespace#84
eleanorfrajka merged 4 commits into
mainfrom
rep/09-layout-polish

Conversation

@eleanorfrajka

Copy link
Copy Markdown
Collaborator

Summary

A broad pass over the report figures, driven by rendering a full ADCP mooring (dsK1_1_2026: ADCP + aquadopp + microcat + rbrsolo + seapoint + tr1050) — cases the clean single-Aquadopp dune2 fixture never exercises. It adds a small title/legend/colour helper layer, standardises font sizes through the mplstyle, fixes several figure-layout bugs, and combines the stack report's hydrography (P/T/S) and velocity (U/V/W) panels into single multi-row figures with one shared instrument legend.

Changes

Title helper — one switch point for panel-title alignment. New Tier-1 primitives plot_title(ax, text) (left-aligned panel title) and figure_title(fig, text) (centred suptitle) in plotters/primitives.py. Every panel-title ax.set_title across current/ts/hydrography/spectrum/diagnostic/timeseries/primitives routes through plot_title, and figure-level suptitles through figure_title, so the left-vs-centre policy is a single edit. Colorbar unit labels (cb.ax/cax.set_title) are deliberately left alone. Fixes the grid N² title (was centred while every sibling panel was left) and the grid velocity suptitle (was clipped off the canvas top; the figure now uses constrained layout).

Font sizes standardised through the mplstyle. Panel titles and suptitles are now 10 pt (axes.titlesize/figure.titlesize, matching the axis labels) and colorbar unit labels 9 pt (ANNOT_FS). All scattered magic fontsize= overrides on titles, axis labels, ticks, and most annotations were removed so they inherit the style; contour labels now use the existing CLABEL_FS token, and the assorted annotation sizes route through ANNOT_FS. Both oceanarray.mplstyle and the vendored config/report.mplstyle were updated (some report figures set their own style context, so both are needed).

Trajectory y-axis labels no longer clipped. The pseudo-Lagrangian trajectory panels lost the leading "N" of "North displacement (km)" once tick labels reached thousands of km. New adaptive helper ytick_reserve_in(y) sizes the left reserve to the widest tick label, and square_axes_grid gained an optional left_in override (mirroring its existing reserve overrides). Short-displacement trajectories keep the full square (no shrink); only wide-label ones reserve extra. Applied to all four trajectory paths (stack aquadopp + ADCP, grid, and the shared plot_trajectory primitive feeding the instrument page). The square/colorbar-height invariant and the fixed slot-width are preserved.

Clock-offset check — colourblind-safe, distinguishable lines. plot_clock_offset_check plotted up to 24+ instruments with tab20 (20 colours, not CVD-safe), so colours collided and were inaccessible. New reusable distinct_line_styles(n) helper (+ OKABE_ITO palette) in plotters/helpers.py cycles the 8-colour colourblind-safe Okabe–Ito set and advances linestyle every 8 lines (solid/dashed/dash-dot/dotted, the sparser styles drawn thicker), so up to 32 lines are each uniquely (colour, linestyle). The shared below-axes legend is also sized to its row count and the figure height grows to fit it, so the legend clears the date-offset labels instead of overlapping the panels.

Rose grid whitespace trimmed. draw_rose_grid set only left/right margins, leaving the matplotlib default top/bottom (~1–2 rows of whitespace on a tall grid); top/bottom are now trimmed to a small fixed inch reserve.

Rotary spectrum readability. draw_grid_rotary_spectrum now shows at most 3 depth levels (the shallowest mapped to near-white), floors the depth colour scale so every kept level is a visible shade, moves the tidal/inertial frequency labels to the top of the panel, and puts the depth legend back at bottom-left with its title dropped so it fits.

Combined hydrography and velocity figures (stack report). New _combined_ts_fig(rows, color_var) builds a stacked multi-variable time series sharing one time axis and one instrument colour scheme (height-ordered), with a single legend over the union of instruments spanning the full figure height. The stack Hydrography section now renders pressure/temperature/salinity as one 3-row figure coloured by the temperature map (dissolved oxygen stays a separate panel — few instruments, no legend problem); the Velocity section renders U/V/W as one 3-row figure. This replaces up to six tall per-variable legends with two, and lets an instrument be followed by colour down the stack. The shared legend anchors to the panels' actual right edge (not the figure edge, which left a gap).

Windows figure (draw_windows): the deploy/recover marker labels are simplified to "YAML" and "Suggested" (was "YAML deploy" / "Sugg. recover" …).

Tests

New test_plotters.py cases: ytick_reserve_in (no-shrink for short labels, monotonic growth, all-NaN fallback), plot_title/figure_title alignment, and distinct_line_styles (unique pairs, palette cycling, linewidth tiers, clamping). test_report_golden.py extended: the PNG-geometry test now also checks row-layout .fig-cell figures so a row panel's declared slot cannot silently diverge from its adapter's render width. The stack golden was re-baselined for the combined-figure structural change (the intended diff). Full suite: 849 passed, 8 skipped; coverage 68%.

Breaking changes

  • Stack report structure changed (output layout). The Hydrography section's pressure/temperature/salinity panels are replaced by a single hydro_pts panel (one 3-row figure), and the Velocity section's east_velocity/north_velocity/up_velocity panels by a single vel_uvw panel. Any code or test keying on those stack panel ids, or on the separate figures, must switch to hydro_pts / vel_uvw. Dissolved oxygen is unchanged.
  • pcolormesh_panel default title_loc changed from "center" to "left". Both in-repo callers already passed "left" explicitly, so rendered output is unchanged; a caller relying on the old centred default would differ.
  • Vendored report style/tokens changed (config/report.mplstyle title sizes, config/report_tokens.py ANNOT_FS 8→9). These are byte-identical-with-ctdcast files; they have been mirrored to ctdcast (ctdcast re-baselines its own PNG-byte golden separately). square_axes_grid gaining left_in is additive (not breaking).

@eleanorfrajka
eleanorfrajka merged commit 4c3a53f into main Aug 19, 2026
5 checks passed
@eleanorfrajka
eleanorfrajka deleted the rep/09-layout-polish branch August 19, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant