FIX: use data values in bar_label#31819
Merged
Merged
Conversation
story645
approved these changes
Jun 4, 2026
Member
|
Good catch! |
timhoffm
approved these changes
Jun 4, 2026
Member
timhoffm
left a comment
There was a problem hiding this comment.
Not using the original data is probably a historic implementation oversight. #15602 was created though many iterations and the datavalues were not originally part of the loop. They just came in via 21da4c1 and when that happened probably nobody thought about that this also simplifies and makes the value formatting more straightforward.
Member
Author
I actually tripped over this one in my day job 😏 |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
This is a minor issue, but...
Currently it is not possible to format bar labels as integers, even if the original data are ints:
The values used are derived from the size of the rectangle, and are therefore always floats. However, the actual data values are also available in this loop, so I'm not clear why we don't directly use them. I wondered if it had to do with unit handling, but the data values on the container have already been processed as
heightorwidthwithinbarmatplotlib/lib/matplotlib/axes/_axes.py
Line 2517 in b825c6d
matplotlib/lib/matplotlib/axes/_axes.py
Line 2523 in b825c6d
matplotlib/lib/matplotlib/axes/_axes.py
Lines 2644 to 2647 in b825c6d
AI Disclosure
No AI used.
PR checklist