{{ message }}
Add group_positions attribute to BarContainer - #32282
Open
robertoffmoura wants to merge 3 commits into
Open
Conversation
Member
|
Thanks for the PR! can you please fill out the AI disclosure bit? Would it also be useful to then provide more information, like bar width, given width also seems to be calculated internally? |
Return the list of bar widths (perpendicular to height), mirroring bottoms, tops, and position_centers. Works consistently for all bar plots across Matplotlib.
Author
|
Thanks for the review! I've updated the PR description with the AI disclosure section. Yes, a |
timhoffm
approved these changes
Sep 4, 2026
timhoffm
left a comment
Member
There was a problem hiding this comment.
This is a reasonable addition. Thanks"
story645
approved these changes
Sep 4, 2026
Member
|
Thanks for the quick turn around. This just needs a what's new entry before it can be merged https://matplotlib.org/devdocs/devel/api_changes.html#release-notes |
Author
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.

Add
group_positionsattribute toBarContainer.Motivation and Context
In
Axes.grouped_bar(),BarContainerinstances are placed at calculated fractional coordinates (lefts). However, the resultingBarContainerinstances inax.containersdo not record the shared categoricalgroup_centersfrom which those fractional offsets were derived.This makes it difficult for downstream converters (such as interactive exporters like Plotly/
matplotlylib) and inspection tools to access the intended group coordinates without resorting to reverse-engineering layout geometry.Following the existing pattern of
BarContainer.datavalues(added forbar_label) andBarContainer.orientation:ax.bar()containers retaingroup_positions = None.Axes.grouped_bar()havebc.group_positions = group_centers.Proposed Changes
group_positions=Noneparameter and attribute toBarContainerinlib/matplotlib/container.pyand its type stubcontainer.pyi.Axes.grouped_bar(), setbc.group_positions = group_centers.bc.group_positionsintest_grouped_bar_return_value.Backwards Compatibility
100% backwards-compatible. Standard
ax.bar()calls default togroup_positions = None.AI Disclosure
AI was used to gain understanding of the existing code and to proof-read the PR description.