Skip to content

Fix misaligned x tick label baselines - #32355

Open
tsumon wants to merge 1 commit into
matplotlib:mainfrom
tsumon:codex/matplotlib-32316
Open

tsumon wants to merge 1 commit into
matplotlib:mainfrom
tsumon:codex/matplotlib-32316

Conversation

@tsumon

@tsumon tsumon commented Sep 16, 2026

Copy link
Copy Markdown

PR summary

The bottom x-axis tick labels currently use top alignment. When custom formatters return labels with different heights, such as pol. and 1, their lower edges do not line up. This change uses baseline alignment for the bottom x-axis tick labels and adds a regression test for the mixed-height label case reported in #32316.

Fixes #32316

AI Disclosure

I used AI assistance to inspect the repository, locate the relevant axis transform and test locations, and review the regression-test setup. I reviewed the final diff and the test output myself. The change is limited to the bottom x-axis text alignment and its regression test; no new dependency or public API is introduced.

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • Plotting related features are demonstrated in an example (N/A: this is a bug fix)
  • New features and API changes have release notes (N/A: no new feature or API change)
  • Documentation complies with general and docstring guidelines

Tests

  • python -m pytest lib/matplotlib/tests/test_axis.py::test_xtick_labels_share_baseline -q (passes with the patched transform; compiled extensions are unavailable in the sparse checkout, so the full source suite could not run locally)
  • python -m compileall -q lib/matplotlib/axes/_base.py lib/matplotlib/tests/test_axis.py
  • git diff --check

@github-actions

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@iccir

iccir commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Hello, please review our AI policy and fill out the original Pull Request Template to let us know about your use of AI. Thanks!

@tsumon

tsumon commented Sep 16, 2026

Copy link
Copy Markdown
Author

I have updated the PR description with the AI disclosure and the official template. The focused regression test passes, but the full CI image-comparison suites now report broad baseline-image changes across existing plots because the bottom x-tick alignment changes from top to baseline globally. I have not regenerated or committed a large set of expected images yet. Could you advise whether the intended direction is to make baseline alignment the new default and update the affected baselines, or to narrow the behavior to the reported custom-label case?

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