FIX: Polar Radial Tick Warnings Labels Bug#31577
Merged
rcomer merged 9 commits intoApr 29, 2026
Merged
Conversation
…bels Extend the FixedLocator isinstance check in Axis.set_ticklabels and _set_formatter to also recognise locators that wrap a FixedLocator via a .base attribute (e.g. RadialLocator used by polar axes). Previously calling set_ticks(ticks, labels) or set_ticklabels(labels) on a polar axis would always hit the else branch and emit a spurious warning because RadialAxis.set_major_locator automatically wraps any locator in a RadialLocator, hiding the inner FixedLocator from the isinstance check. Add a regression test covering both the combined set_ticks path and the separate set_rticks / set_ticklabels path, and asserting that a label count mismatch still raises ValueError. Also add python_version = "3.11" to [tool.mypy] and target-version = "py311" to [tool.ruff] in pyproject.toml to match the project's minimum supported Python version, and update .pyi stub imports accordingly.
Contributor
Author
|
Not sure if the code coverage issue is a blocker, let me know. |
rcomer
reviewed
Apr 28, 2026
rcomer
left a comment
Member
There was a problem hiding this comment.
Thanks @beelauuu. Codecov is currently for information only and I'm happy that the actual change is covered, so no problem there.
rcomer
reviewed
Apr 28, 2026
timhoffm
reviewed
Apr 28, 2026
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
timhoffm
approved these changes
Apr 29, 2026
| # the "set_ticklabels() should only be used with a fixed number of ticks" | ||
| # UserWarning when set_ticks()/set_rticks() was called first. | ||
|
|
||
| # Path 1: set_rticks then set_ticklabels separately |
Member
There was a problem hiding this comment.
Suggested change
| # Path 1: set_rticks then set_ticklabels separately |
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
rcomer
approved these changes
Apr 29, 2026
rcomer
pushed a commit
that referenced
this pull request
Apr 29, 2026
rcomer
added a commit
that referenced
this pull request
Apr 29, 2026
Co-authored-by: Brian Lau <103338659+beelauuu@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Closes #31574
Minimal fix (for now) for
set_ticks(ticks, labels)orset_ticklabels(labels)on a polar axes emitting a spuriousUserWarning:The fix extends both the
set_ticklabelsand_set_formatterguards to also match locators that wrap aFixedLocatorvia a.baseattribute, using duck-typing to avoid importingRadialLocatorintoaxis.py.AI Disclosure
Claude helped identify the root cause, write the regression test, and diagnose some pre-commit hook configuration issues I was having (python_version / target-version missing from pyproject.toml).
PR checklist
https://matplotlib.org/devdocs/devel/document.html#write-docstrings guidelines