Skip to content

BUG: align custom x tick label baselines - #32423

Open
QianyeSu wants to merge 2 commits into
matplotlib:mainfrom
QianyeSu:fix/32316-xticklabel-baselines
Open

QianyeSu wants to merge 2 commits into
matplotlib:mainfrom
QianyeSu:fix/32316-xticklabel-baselines

Conversation

@QianyeSu

@QianyeSu QianyeSu commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #32316.

Summary

  • Keep the line box used by custom, unrotated x tick labels large enough for the font's lp metrics.
  • This keeps labels with different ascenders (for example, "pol." and "1") on a common baseline after the text metric changes in 3.11.
  • Add a regression test and update the affected image baselines.

The adjustment is limited to labels produced by a FuncFormatter; default numeric tick formatting, fixed labels, and rotated labels retain their existing layout behavior.

Tests

  • MPLBACKEND=Agg ./.venv/bin/pytest -q lib/matplotlib/tests/test_text.py lib/matplotlib/tests/test_axes.py lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py lib/mpl_toolkits/mplot3d/tests/test_axes3d.py lib/matplotlib/tests/test_colorbar.py
  • python -m compileall -q lib/matplotlib/axis.py lib/matplotlib/text.py lib/matplotlib/tests/test_text.py
  • git diff --check

The focused Matplotlib test run passed with 1338 passed, 91 skipped.

AI Disclosure

I used an AI coding assistant to help investigate the regression, draft the implementation, and run the tests. I reviewed the changes, the resulting baseline images, and the test output before opening this pull request.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 09:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@QianyeSu
QianyeSu force-pushed the fix/32316-xticklabel-baselines branch 2 times, most recently from 44a5dff to 09d21bf Compare October 2, 2026 09:52
@QianyeSu
QianyeSu force-pushed the fix/32316-xticklabel-baselines branch from 09d21bf to 96340c1 Compare October 2, 2026 11:21
@QianyeSu

QianyeSu commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

I pushed commit 3d7365a040 to address the remaining cross-platform image failures.

The first CI run showed that set_ticklabels() internally uses a FuncFormatter, so it was incorrectly included in the new custom-formatter baseline path. This commit marks that internal formatter as fixed-label formatting and leaves its existing layout unchanged. The affected set_get_ticklabels, colorbar, subfigure, and 3D image tests pass locally against the upstream baselines; the regression test for the reported custom formatter still passes.

The free-threaded Linux job had 3 image failures (all baseline/layout comparisons, no Python exceptions). A new CI run is now queued for the narrowed change.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: misaligned between xticklabel baselines

2 participants