Skip to content

Use FixedFormatter only with FixedLocator - #15507

Merged
anntzer merged 1 commit into
matplotlib:masterfrom
timhoffm:fixed-formatter
Dec 30, 2019
Merged

anntzer merged 1 commit into
matplotlib:masterfrom
timhoffm:fixed-formatter

Conversation

@timhoffm

@timhoffm timhoffm commented Oct 24, 2019 •

Copy link
Copy Markdown
Member

PR Summary

This PR prevents users from stumbling into #7122, #8779, #15501.
It does not technically fix them, FixedFormatter has a one-off bug with locators other than FixedLocator. But setting fixed labels at unknown positions is anyway not a good idea. So even if the one-off bug was fixed FixedFormatter should only used with FixedLocator.

  • This PR mostly documents that FixedFormatter should not be used without a FixedLocator (along the hierarchy of tick label setter methods).
  • Additionally it warns on the lowest level set_major/minor_formatter() if a FixedFormatter is set without a FixedLocator. This may be debatable.
    One could set the formatter first and the locator afterwards, which would technically yield the correct result. However, I feel that setting the position first and the labels second is the natural way, and is actually done throughout the library.
    No alternative: Since Formatters don't know about Locators FixedFormatter itself cannot check at runtime and we have to resort to this somewhat clumsy approach.
    And I strongly want some feedback on this potential problem from running code, because nobody reads the docs 😄.
  • One could consider captureing and re-emitting warnings on the higher levels with more appropriate messages, but I felt this was too much fuss.

@tacaswell tacaswell added this to the v3.3.0 milestone Oct 25, 2019
@tacaswell

Copy link
Copy Markdown
Member

Seems reasonable, but fails 15 tests!

@timhoffm
timhoffm force-pushed the fixed-formatter branch 2 times, most recently from 4f9a9fe to 332cb4a Compare October 27, 2019 21:02
@timhoffm timhoffm added API: consistency Consistency of the matplotlib API, including naming, behavior, defaults, … status: needs review labels Oct 28, 2019
Comment thread lib/matplotlib/axis.py Resolved
@jklymak

jklymak commented Nov 1, 2019

Copy link
Copy Markdown
Member

TypeError: _warn_external() got an unexpected keyword argument 'stacklevel' 😉

Comment thread lib/matplotlib/axis.py Resolved
@timhoffm
timhoffm force-pushed the fixed-formatter branch 2 times, most recently from 578236a to 29b63c7 Compare November 1, 2019 17:39
Comment thread lib/matplotlib/axes/_base.py Resolved
anntzer
anntzer previously approved these changes Dec 2, 2019

@anntzer anntzer 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.

just one nit

Comment thread lib/matplotlib/axis.py Resolved
@anntzer
anntzer dismissed their stale review December 2, 2019 18:30

actually a real (minor) thing to fix on the warning too

@timhoffm
timhoffm force-pushed the fixed-formatter branch 2 times, most recently from 8481e72 to a473ba1 Compare December 3, 2019 05:17
@timhoffm

Copy link
Copy Markdown
Member Author

Ping @anntzer warning fixed.

@anntzer
anntzer merged commit 642b034 into matplotlib:master Dec 30, 2019
@timhoffm
timhoffm deleted the fixed-formatter branch December 30, 2019 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: consistency Consistency of the matplotlib API, including naming, behavior, defaults, …

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants