Skip to content

[FIX] Report plot polish — colorbar ticks, cyclic direction, T-S bounds, tilt panels - #83

Merged
eleanorfrajka merged 1 commit into
mainfrom
rep/08-plot-polish
Aug 18, 2026
Merged

[FIX] Report plot polish — colorbar ticks, cyclic direction, T-S bounds, tilt panels#83
eleanorfrajka merged 1 commit into
mainfrom
rep/08-plot-polish

Conversation

@eleanorfrajka

Copy link
Copy Markdown
Collaborator

Summary

A round of figure fixes to the grid and stack report plots, found by eyeballing the rendered reports. No manifest or template changes — this is the plotter/adapter layer only.

Changes

Discrete-colorbar tick alignment. _nice_colorbar_bounds snapped the boundary step to any 1-significant-figure value (0.03, 30), so round labelled ticks (0.2, 100) landed between the colour steps. It now snaps the step to the nice 1 / 2 / 2.5 / 5 family (as MaxNLocator uses) and aligns the boundaries to integer multiples spanning the data, so labelled ticks fall on colour-step boundaries. Fixes the grid σ₀ stratification panel and the stack T-S pressure and count-heatmap colorbars. The boundary count is now adaptive (~n) rather than a fixed n+1.

Buoyancy frequency N² colour limits. draw_grid_n2 took the 2.5/97.5 percentile of log10(N²) including the 1e-12 floor applied to non-positive (unstable) cells, so whenever more than a few percent of cells were unstable the low limit pegged at −12 and washed out the structure. Limits now come from the 1st/99th percentile of log10(N²) over positive cells only; unstable cells still render as the lowest colour (off-scale low).

Current-direction colorbar is now truly cyclic. twilight has 510 native colours, so BoundaryNorm(ncolors=256) mapped 0–360° onto only the first half of the cycle (pale→dark) — 0° and 360° looked different. The direction panel now resamples twilight to one colour per bin and matches ncolors, so the full cycle shows and 0° == 360°.

T-S diagram axis bounds. Both the stack (draw_stack_ts_diagram) and grid (draw_grid_ts_diagram) T-S panels set axis limits from the full data min/max (grid used the 0.01/99.99 percentiles), so outliers stretched the box with whitespace. A new _nice_axis_limits helper takes the 1st/99th percentiles, pads 5% of that range on each side, and rounds outward to a clean step.

Aquadopp tilt panels (_make_aquadopp_tilt_panels, stack section 9): gridlines on both the time-series and scatter panels; the scatter shares the time-series y-axis per row on a fixed 0–90° scale with matched x/y ticks (0/30/60/90); panel height reduced to 80%; inter-row spacing tightened with x-labels/ticks on the bottom row only.

Tests

test_utilities.py: the two _nice_colorbar_bounds tests updated for the adaptive count and nice step, plus a new regression guard that labelled ticks land on colour boundaries. test_plotters.py: two new tests for _nice_axis_limits (padding/rounding and outlier exclusion). Full suite 843 passed. The golden report test stays green because it masks PNG bytes; these are visual changes so no re-baseline was needed.

Coverage note

One new branch is unexercised by the dune2 fixture: the tilt panels' upper-row x-tick suppression only runs with more than one Aquadopp, and dune2 has a single one. Covering it needs a multi-Aquadopp fixture.

Breaking changes

None to the public API. Two internal signatures shifted: _nice_colorbar_bounds now returns an adaptive-length boundary array (was fixed n+1), and _velocity_panel_style returns a Colormap object for the direction panel (was a name string). Both are private (leading underscore) and their callers already accept the new forms.

@eleanorfrajka
eleanorfrajka merged commit b88497b into main Aug 18, 2026
5 checks passed
@eleanorfrajka
eleanorfrajka deleted the rep/08-plot-polish branch August 18, 2026 17:44
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