Fix pyplot autoscale margins and bar extents [mpl compatibility]#240
Fix pyplot autoscale margins and bar extents [mpl compatibility]#240sselvakumaran wants to merge 17 commits into
Conversation
Greptile SummaryThis PR updates pyplot autoscaling and label geometry to match Matplotlib-style margins. The main changes are:
Confidence Score: 5/5This PR appears safe to merge with low risk. The changes are focused on autoscale range propagation and render geometry, with broad tests for the affected pyplot, core, SVG/raster, and browser paths. No verified correctness or security issues were found in the changed code. No files require special attention.
What T-Rex did
Important Files Changed
Reviews (7): Last reviewed commit: "Remove visual comparison asset" | Re-trigger Greptile |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Correction to the earlier visual: that panel compared two XY revisions, not Matplotlib directly. This one renders the same calls in Matplotlib 3.11 and XY: What the Matplotlib source and direct measurements show:
The separate tick-label fix is also included: padding starts after the outward end of the tick, and the browser geometry test measures the requested 5 px gap after a 6 px tick. Validation: 710 passed, 3 skipped, plus the focused browser geometry test. |
There was a problem hiding this comment.
This repository has used its 100 free open-source review credits for this billing period. An organization admin can enable additional billed reviews, or reviews resume next period.
The shared tick-label offset helper derived the spine-to-label gap from tick geometry unconditionally. Core's default `tick_length` is 0 and there is no default `tick_label_pad`, so every chart that authored no tick styling had its tick labels pulled toward the spine — a layout change core users did not ask for. Pyplot was unaffected because it always supplies mpl's tick size and pad from rcParams. Gate the derived geometry on whether the axis actually authored `tick_length`/`tick_label_pad`, and give each renderer its own per-side unauthored default, chosen so an unstyled chart reproduces the previous placement exactly: 16/7/8 px (bottom/top/y) plus a flat 4 px y baseline nudge in the SVG exporter, 15/7/8 plus 4 in the native raster, and 6/18/8 in the browser client. Those gaps were already asymmetric per side, so per-side defaults are the existing contract rather than an approximation. Whole-file SVG strings and whole rasterized RGBA frames now match the pre-`tick_label_pad` output byte for byte for unstyled charts, including top/right sides, non-default tick fonts, and staggered label rows. The authored path is untouched, so pyplot spacing is unchanged. Pin the geometry in tests on both exporters (real coordinates, not tolerances) and pin the browser client's per-side defaults at the source, since this suite has no browser. Document `tick_label_pad` and the two placement regimes in spec/api/styling.md, and the new `margin` axis option alongside `domain`/`bounds` in spec/design/pan-and-zoom-configuration.md.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |







Summary
Validation
pytest -q tests/pyplot— 623 passed, 3 skippedruff check— passedruff format --check— passedgit diff --check— passedThe visual micro-suite also confirms line views now use the expected 5% limits and ordinary/stacked/horizontal bar labels remain inside the rendered view.