Skip to content

Complete axes outer-label and margin semantics [codex bughunt] - #355

Merged
sselvakumaran merged 2 commits into
agent/bughunt-authored-style-parityfrom
agent/bughunt-axes-helper-parity
Jul 28, 2026
Merged

Complete axes outer-label and margin semantics [codex bughunt]#355
sselvakumaran merged 2 commits into
agent/bughunt-authored-style-parityfrom
agent/bughunt-axes-helper-parity

Conversation

@sselvakumaran

@sselvakumaran sselvakumaran commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • implement Axes.label_outer(remove_inner_ticks=False) using the complete GridSpec span, including top/right label positions and optional inner-tick removal
  • make Axes.margins() return the configured margins and reject mixed positional/keyword values without mutating state
  • preserve Matplotlib's tight=True / False / None autoscale state across margins, live autoscale requests, disabled axes, and axis(...) modes
  • keep free-form add_axes() instances unchanged

Why

label_outer() was a no-op, so scientific subplot grids retained repeated interior labels and crowded their gutters. The margin API also differed in getter, argument-conflict, and round-number autoscale behavior. These are general shim semantics, not example-specific fixes.

This is stack layer 2, based on #351. It should be reviewed and merged after #351.

Visual acceptance

Exact comparison: Matplotlib 3.11.0 / XY before 074122d9b702fa16bdf8b78b318eb5b483e869b3 / XY after 06c7aeddb413f5fed49918cff26758797bde78aa.

Matplotlib reference, XY before, and XY after

The reproduction scripts and individual panels are on the evidence-only branch at commit 22c5de9170a7f080c6a8751db35c153bae15ac09; no review assets are included in this product diff.

Verification

  • 159 focused and adjacent autoscale/axis/gallery tests passed during implementation
  • final focused and adjacent selection after review fixes: 84 passed
  • two independent parity re-reviews: clean
  • CodeRabbit's live-autoscale finding was verified and fixed; later data now expands tight autoscaled axes
  • uv run --with pre-commit pre-commit run --all-files
  • uv run ruff check .
  • uv run ruff format --check .
  • git diff --check

No browser process was used for this shim-only layer.

Summary by CodeRabbit

  • New Features

    • Added Matplotlib-compatible outer labeling for subplot grids, with an option to remove inner tick marks.
    • margins() can now report current margin settings as well as update them.
    • Improved autoscaling controls, including optional tight scaling and support for selectively recomputing axis limits.
    • Added more consistent behavior for axis("tight"), axis("image"), and related modes.
  • Bug Fixes

    • Prevented automatic “round number” expansion when tight scaling is enabled.
    • Improved preservation of explicit limits and margin settings during autoscaling.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sselvakumaran, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bb2b98a3-1e5e-4d60-836e-7047250351ab

📥 Commits

Reviewing files that changed from the base of the PR and between 06c7aed and 6de8b45.

📒 Files selected for processing (2)
  • python/xy/pyplot/_axes.py
  • tests/pyplot/test_axes_outer_label_margin_parity.py
📝 Walkthrough

Walkthrough

Changes

Axes behavior updates

Layer / File(s) Summary
Tight state and autoscale transitions
python/xy/pyplot/_axes.py, tests/pyplot/test_axes_outer_label_margin_parity.py
Axes tracks tight state across axis modes, margins, autoscaling, domain rebuilding, and round-number limit expansion. Tests cover getters, argument validation, state transitions, explicit limits, and resulting ranges.
Grid-aware outer labels
python/xy/pyplot/_axes.py, tests/pyplot/test_axes_outer_label_margin_parity.py
label_outer() now handles GridSpec boundaries, label positions, inner ticks, spanning subplots, and free-form axes. Tests cover each behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Axes.autoscale_view
  participant Axes._set_tight_domains
  participant _build_chart_uncached
  Caller->>Axes.autoscale_view: provide tight state
  Axes.autoscale_view->>Axes._set_tight_domains: update tight domains
  Axes._set_tight_domains->>_build_chart_uncached: rebuild chart limits
  _build_chart_uncached-->>Caller: return updated limits
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: completing outer-label behavior and margin/autoscale semantics.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/bughunt-axes-helper-parity

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 103 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing agent/bughunt-axes-helper-parity (6de8b45) with main (55b0ca8)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on agent/bughunt-authored-style-parity (59f07bb) during the generation of this report, so main (55b0ca8) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/xy/pyplot/_axes.py (1)

4795-4838: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

tight=True should not freeze autoscaling
autoscale(..., tight=True) currently writes a fixed domain and adds the axis to _explicit_domains, so later data updates and margins() calls stop affecting that axis. Matplotlib keeps autoscaling active here; only the margin state should change, and autoscale_view(tight=True) should still honor the configured margins instead of snapping to _entry_extent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/xy/pyplot/_axes.py` around lines 4795 - 4838, Update autoscale so
tight=True only updates the tight/margin state and does not write a fixed domain
or add axes to _explicit_domains; preserve active autoscaling for subsequent
data updates and margins() calls. In autoscale_view, ensure tight=True uses the
configured margins rather than snapping limits to _entry_extent, while retaining
explicit-domain behavior for disabled autoscaling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@python/xy/pyplot/_axes.py`:
- Around line 4795-4838: Update autoscale so tight=True only updates the
tight/margin state and does not write a fixed domain or add axes to
_explicit_domains; preserve active autoscaling for subsequent data updates and
margins() calls. In autoscale_view, ensure tight=True uses the configured
margins rather than snapping limits to _entry_extent, while retaining
explicit-domain behavior for disabled autoscaling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c94a4e7-1f76-429d-8e03-ba40a4144b16

📥 Commits

Reviewing files that changed from the base of the PR and between 074122d and ac3fa14.

📒 Files selected for processing (2)
  • python/xy/pyplot/_axes.py
  • tests/pyplot/test_axes_outer_label_margin_parity.py

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sselvakumaran
sselvakumaran force-pushed the agent/bughunt-axes-helper-parity branch from 3f7baf9 to 6de8b45 Compare July 28, 2026 00:03

Copy link
Copy Markdown
Contributor Author

Restacked cleanly onto the updated #351 head; the PR-relative stable patch ID is unchanged. The earlier live-autoscale finding remains fixed in the current layer. Full repository hooks, Ruff, formatting, and git diff --check pass on the rebased tree.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

The PR description image shows a three-column visual comparison: “Matplotlib 3.11 reference”, “XY before”, and “XY after.” Each column contains four plots titled Experiment 1–4, with colored line-and-circle-marker series (blue, red, green, purple), x-axis label “Elapsed time (hours)”, and y-axis label “Measured response (units)”. The “XY after” plots visually align with the Matplotlib reference in label placement and subplot presentation, while retaining the same data trends as “XY before.”

@sselvakumaran Thanks—the current restacked layer will be reviewed against the updated #351 base, including the retained live-autoscale behavior.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sselvakumaran
sselvakumaran merged commit 6de8b45 into main Jul 28, 2026
39 of 40 checks passed
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