Axis tick-label anchoring, figure-background theming, and rule-label styling#75
Conversation
Engine features, honored by the live client and static SVG/PNG exports alike: - tick_label_anchor on x_axis/y_axis and as a slot style (mpl ha aliases normalize): which label edge pins to the tick; rotated tick labels pivot about the pinned edge. - theme(background=) is the figure background (mpl figure.facecolor), painting the whole card (margins, title, tick labels); --chart-bg / plot_background now scopes to the plot rect only. - Rule/annotation label styling: dash strings, vertical_align, padding offsets. Showcased by the new examples/demo-advance.ipynb (benchmark-style bar chart + ExploitBench line/scatter recreation) and its Chromium-engine PNG build at examples/exploitbench.png.
5a39071 to
69ec1f9
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
# Conflicts: # js/src/20_theme.js # js/src/50_chartview.js # python/xy/_raster.py # python/xy/_svg.py # python/xy/static/index.js # python/xy/static/standalone.js # tests/test_components.py
Arrow labels no longer sit exactly on the shaft midpoint: the client lifts them along the shaft's upward normal so the line doesn't strike through the text (#63). The alignment probe still asserted the old center-x-equals-midpoint contract and failed once a Chromium is available (CI skips these probes). Assert the new geometry instead: no tangential drift along the shaft, and a normal offset large enough that the label box clears the line.
|
Reviewed this with a focus on the client/export parity claims. One blocking issue, a couple of smaller notes. Blocking: export/client tick-label collision parity is broken for anchored labels The JS client gained an anchor-aware collision model ( Concrete repro, using this PR's own demo chart (9 category labels, Non-blocking:
Everything else checked out: wire contract validation/normalization of |
|
@copilot resolve the merge conflicts in this pull request |
The _axis_tick_label_layout collision check now uses the same
edge-anchor-aware model as JS _tickLabelsCollide:
- For is_x=True and anchor != "center": rotated labels use the
perpendicular-gap test (spacing * sin(angle) < lineHeight + minGap)
instead of the old centered half-extent boxes. Non-rotated edge-
anchored labels check the width of the "lead" label (end → current,
start → previous) against spacing.
- For y-axis or centered x-axis: the original centered-extent model
is unchanged (parity with JS comment: "y collision keeps the
centered extent model").
Adds test_svg_tick_label_anchor_collision_parity to confirm that 9
rotated edge-anchored labels are all kept when spacing * sin(angle)
exceeds the threshold, and that the unanchored (centered) path still
detects the same geometry as a collision.
Fixes: blocking issue from PR review — export was stride-2 downsampling
labels that the JS client kept (and vice-versa for shallow angles).
Fixed the blocking issue in commit
Added The merge conflicts were resolved in the earlier
Merge conflicts are already resolved — the |


Engine features
Honored by the live client and the static SVG/PNG exports alike:
tick_label_anchoronx_axis/y_axisand as a slot style (mplhaaliasesleft/right/middlenormalize) — selects which label edge pins to the tick; rotated tick labels pivot about the pinned edge. This is the mplha=semantic the pyplot shim emits for slanted categorical labels.theme(background=)is the figure background (mplfigure.facecolor): it paints the whole card — margins, title, tick labels — and shows through the plot rect.--chart-bg/plot_backgroundnow scopes to the plot rect only (mplaxes.facecolor). Static exports reproduce both fills.vertical_align, and padding offsets on annotation labels.Docs updated in
docs/engineering/styling.md; parity tests across components, CSS mark styles, SVG/PNG export, and pyplot layout no-ops.