Skip to content

FIX: better default spine path (for logit) #11417

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 2 commits into from
Jun 13, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Jun 11, 2018

PR Summary

Closes #11386; see also #11404 which fixes the errors for tight_layout and constrained_layout.

import matplotlib.pyplot as plt

fig, ax = plt. subplots()
ax.plot([0.1, 0.2, 0.6, 0.9])
ax.set_yscale('logit')
ax.set_ylabel('Boo')

plt.show()

gives a warning, and does not show the ylabel. Issue is that the yaxis spine path is

Path(array([[  0.,  13.],
       [  0.,  13.]]), None)

and _update_label_position needs a valid path to get started, whereas the logit scale injects Infs.

This PR changes the default PATH to something that would theoretically fit on the figures (and hence all values are less than 1).

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@dstansby
Copy link
Member

Could this or #11404 get a test? (just the code that is in #11386 would probably be fine)

@jklymak
Copy link
Member Author

jklymak commented Jun 12, 2018

@dstansby Thanks,; new test fails on master, passes on this PR.

@jklymak jklymak force-pushed the fix-better-default-spine-path branch from 9f38fd6 to e213f4b Compare June 12, 2018 17:27
Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Seems like a bit of a bodge that should be fixed properly elsewhere, but if it works it works for now.

@dstansby dstansby added this to the v3.0 milestone Jun 12, 2018
@jklymak
Copy link
Member Author

jklymak commented Jun 12, 2018

Hmmm, well, the problem is logit transform, which doesnt do sensible things if the values passed to it are not 0<a<1. It has a "clip" argument, but we don't call transforms with clip turned on, so. Conversely, you may not want to always clip data sent to the transform, because maybe you want to tell the user its gone to infinity....

The other solution that occured to me is getting the spine Path to resolve itself properly earlier, but that seemed hard, and unecessary.

@phobson
Copy link
Member

phobson commented Jun 12, 2018

I should probably write a similar test for mpl-probscale, which is very similar to logit scales

@phobson phobson merged commit 928d6d5 into matplotlib:master Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logit scale doesn't position x/ylabel correctly first draw
3 participants