Skip to content

Use FixedFormatter only with FixedLocator #15507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2019

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Oct 24, 2019

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
Member

Seems reasonable, but fails 15 tests!

@jklymak
Copy link
Member

jklymak commented Nov 1, 2019

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

@timhoffm timhoffm force-pushed the fixed-formatter branch 2 times, most recently from 578236a to 29b63c7 Compare November 1, 2019 17:39
anntzer
anntzer previously approved these changes Dec 2, 2019
Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

just one nit

@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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants