Skip to content

Fix axis and tick-label APIs [mpl compatibility] - #244

Closed
sselvakumaran wants to merge 8 commits into
mainfrom
agent/axis-tick-api-compat-perfrepro
Closed

Fix axis and tick-label APIs [mpl compatibility]#244
sselvakumaran wants to merge 8 commits into
mainfrom
agent/axis-tick-api-compat-perfrepro

Conversation

@sselvakumaran

Copy link
Copy Markdown
Contributor

Summary

Add the missing Matplotlib 3.11 axis/tick compatibility surface used across the static gallery:

  • set_xticklabels / set_yticklabels, including empty-label hiding and FixedLocator length checks
  • per-axis xaxis.grid(...) / yaxis.grid(...)
  • tick side and label-side visibility flags
  • rotation_mode / labelrotation_mode and tick-label rotation handles
  • independent x/y grid state instead of forcing the other axis off

This branch deliberately excludes all autoscale-margin behavior owned by #240.

Gallery reference

Before / Matplotlib / after

Multiple figures tick-label comparison

Before, set_xticklabels([]) aborts the gallery and the upper axes' labels collide with the lower axes. After, both figures complete and the intended upper tick labels are hidden.

The APIs also move several additional gallery files past their prior crashes. I am not claiming those visually complete here: boxplot_vs_violin.py reaches an existing boxplot geometry defect, and auto_ticks.py still needs #240's margin API.

Verification

  • 541 passed, 65 skipped in tests/pyplot
  • multiple_figs_demo.py: both PNG captures complete
  • focused axis/tick/grid tests: 34 passed
  • Ruff, format check, and git diff --check pass

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 24%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 102 untouched benchmarks
⏩ 1 skipped benchmark1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_select_lasso_message_1m 90.5 ms 119.1 ms -24%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing agent/axis-tick-api-compat-perfrepro (3f3d5c3) with main (989a3a7)2

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

  2. No successful run was found on main (bf903bc) during the generation of this report, so 989a3a7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sselvakumaran

Copy link
Copy Markdown
Contributor Author

seems like this fix is fine, but other issues that might be fixed with other PRs:

  • the orange samples / line extend over the bounds in width
  • tick numbers / labels are still too close to the actual ticks / axis especially on the x-axis (when text is below the axes)

@sselvakumaran sselvakumaran changed the title Add pyplot axis and tick-label gallery APIs Fix axis and tick-label APIs [mpl compatibility] Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 351f75dd-2734-4365-941e-d63920ab83d4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/axis-tick-api-compat-perfrepro

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

Copy link
Copy Markdown
Contributor Author

Addressed the tick-label spacing feedback in ada03c5.

Exact before/reference/after tick spacing comparison with 2x zoom

Matplotlib has two independent defaults here: a 3.5 pt major-tick length and a further 3.5 pt label pad. XY emitted the tick length but then placed labels with fixed renderer offsets, leaving roughly 1 px between the outward tick and its label. The browser, SVG, and PNG renderers now place labels after outward tick length + tick padding; pyplot supplies the rc-driven defaults and tick_params(pad=...) can override them, including Matplotlib-compatible negative padding.

The orange line touching the x limits is the separate autoscale-domain issue owned by #240, so I did not duplicate that change here.

Verification:

  • 109 focused pyplot/style/SVG/security tests passed.
  • Ruff, formatting, git diff --check, JS typecheck, and client build passed.
  • The exact 88-example Matplotlib 3.11 scoped rerender completed with all 54 in-scope examples still paired.

I also audited the existing CodSpeed red. It only flags the unrelated test_select_lasso_message_1m row and explicitly warns that base/head used different runtime environments. The benchmark, selection/channel code, and native timed path are identical to main; this PR's tick renderer is not imported by that timed call. Local repeated 1M lasso runs stayed at a 12.7 ms median. There is no causal selection performance fix to make in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant