Conversation
|
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. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
Hello, please review our AI policy and fill out the original Pull Request Template to let us know about your use of AI. Thanks! |
|
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? |
The issue originally appeared in 97f4943 in text.py's |
|
Updated the PR based on your feedback. The global x-axis transform change has been reverted. The fix now lives in Text._get_layout(): for single-line, horizontal, top-aligned text, labels whose measured ascent exceeds the font ascent are offset to the stable font baseline, while labels that already match it keep their existing position. The regression test remains focused on the reported pol. / 1 case. The targeted reproduction passes, and compileall plus git diff --check pass locally; the sparse checkout does not contain the compiled extensions needed to run the full Matplotlib suite locally. |
|
I narrowed the fix further after the image-comparison failures. The previous revision still affected unrelated top-aligned text. The new commit a3cfabc marks only X-axis tick labels and gates the Text._get_layout adjustment on that marker; the global axis transform remains reverted. The targeted reproduction passes, and ordinary top-aligned Text remains unchanged in the local check. CI is running again. |
PR summary
The bottom x-axis tick labels currently use top alignment. When custom formatters return labels with different heights, such as
pol.and1, 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
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.pygit diff --check