-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
DOC: modernise barh example #30973
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
DOC: modernise barh example #30973
Conversation
|
|
||
| ax.barh(people, performance, xerr=error, align='center') | ||
| ax.invert_yaxis() # labels read top-to-bottom | ||
| ax.yaxis.set_inverted(True) # labels read top-to-bottom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is preferred to ax.invert_yaxis ? Not sure I understand that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/matplotlib/matplotlib/pull/13330/changes#diff-23b7fa7a4b346c0e303ac8bc2158c701c855dc79256dff8bfadbaa9df62307e5: the problem of invert_yaxis is that it is brittle if you don't control the whole axes life-cycle, which easily occurs if your code ends up refactored in a separate function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"invert" means "to reverse in position, order, or relationship". It doesn't matter if the axis has been inverted before, it's just a toggle, so I don't see the brittleness
fig, ax = plt.subplots()
ax.plot(np.arange(10))
ax.invert_yaxis()
ax.invert_yaxis()
yields a yaxis that has 0 on the bottom and 9 on the top
|
I think this kind of minimal example should just use some made-up data ( |
|
@rcomer thanks for immediately taking action on adding fixed data. |
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
PR summary