FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: better default spine path (for logit) by jklymak · Pull Request #11417 · matplotlib/matplotlib · GitHub

Repository navigation

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

Merged
phobson merged 2 commits into
matplotlib:masterfrom
jklymak:fix-better-default-spine-path
Jun 13, 2018
Merged

phobson merged 2 commits into
matplotlib:masterfrom
jklymak:fix-better-default-spine-path

Conversation

jklymak commented Jun 11, 2018 •
edited
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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

jklymak commented Jun 12, 2018

Copy link
Copy Markdown
Member Author

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

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

dstansby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

dstansby added this to the v3.0 milestone Jun 12, 2018

jklymak commented Jun 12, 2018

Copy link
Copy Markdown
Member Author

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 commented Jun 12, 2018

Copy link
Copy Markdown
Member

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

phobson merged commit 928d6d5 into matplotlib:master Jun 13, 2018
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

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


Back | FazBrowse Home | New Git URL