-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enh/Add hatch pattern support to Axes.grouped_bar #30726
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
Open
ilakkmanoharan
wants to merge
17
commits into
matplotlib:main
Choose a base branch
from
ilakkmanoharan:enh/grouped-bar-hatch-broadcast-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cd9ddcd
Enhance grouped_bar: refine hatch handling, type hints, and tests
ilakkmanoharan 6e3a7c8
Sync pyplot boilerplate after grouped_bar signature change
ilakkmanoharan dc94475
Sync pyplot boilerplate after grouped_bar signature change
ilakkmanoharan b402730
Remove ValueError docstring note, drop TODOs
ilakkmanoharan 90f0a22
Trigger CI rerun: retry Windows backend timeouts
ilakkmanoharan 0fad966
Trigger CI rerun: retry WebAgg timeout
ilakkmanoharan 1eb63f9
Trigger CI rerun: retry backend timeout
ilakkmanoharan 960914c
Trigger CI rerun: retry TkAgg timeout
ilakkmanoharan adf2717
Update lib/matplotlib/axes/_axes.py
ilakkmanoharan a8c8705
Allow None entries in hatch list for grouped_bar()
ilakkmanoharan d2f1943
CI: rerun tests
ilakkmanoharan afb64cb
Docstring: clarify 'hatch' parameter type as sequence of :mpltype: or…
ilakkmanoharan 485ef67
Update lib/matplotlib/axes/_axes.py
ilakkmanoharan 9fffd16
Clean up API change entry for grouped_bar hatch behavior
ilakkmanoharan af21213
Fix hatch validation: disallow empty lists
ilakkmanoharan 541bf68
Trigger CI/CD
ilakkmanoharan 324d578
Update lib/matplotlib/axes/_axes.py
ilakkmanoharan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
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.
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.
can you condense the whitespace please?
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.
Also, why not just follow the pattern in hist and allow a string (since we're allowing 1d list) and therefore simplify the error checking - basically bar handles the hatch validation instead of grouped bar.
https://github.com/matplotlib/matplotlib/blob/dedfe9be48ad82cade86766ef89410844ff09b31/lib/matplotlib/axes/_axes.py#L7560C8-L7560C76
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.
When hatch is given as a single string (e.g. "//"), we raise a ValueError. This prevents Matplotlib from incorrectly iterating over individual characters ('/', '/') instead of treating the hatch as a single pattern.
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.
@story645 @timhoffm
https://github.com/matplotlib/matplotlib/blob/dedfe9be48ad82cade86766ef89410844ff09b31/lib/matplotlib/axes/_axes.py#L7560C8-L7560C76 --->>>>>> the implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset generates multiple patches. This causes the hatch sequence to repeat incorrectly within the same dataset.
I am wondering if we need to replace the patch-level cycling with a dataset-level normalization instead? Specifically:
determine the number of datasets (num_datasets = len(heights)),
normalize hatch to one pattern per dataset, and
apply that hatch consistently to all patches for that dataset.
This would align hatch behavior with how color and label are already broadcast in grouped_bar, and it also resolves the test failures caused by per-patch cycling.
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.
Sounds good to me, I think would also then allow for easier expansion into nesting (hatch per patch per dataset) if we wanted to go that direction.
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.
[MNT]: Discussion : Normalize hatch patterns per dataset instead of per patch in grouped_bar #30789
I’ve created a new issue to address the hatch-normalization behavior in grouped_bar (i.e., switching from per-patch hatch cycling to per-dataset hatch assignment). This allows us to track that behavioral change separately from PR #30726, which is already large and focused on adding hatch support. Splitting this out avoids scope creep, keeps the current PR reviewable, and ensures the semantic change to hatch handling receives dedicated discussion and review.
@timhoffm @story645
Uh oh!
There was an error while loading. Please reload this page.
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.
@ilakkmanoharan I closed that issue b/c that behavioral discussion is necessary in this PR to move this PR forward - it's not scope creep b/c it's inherent to how you're handling the hatch argument and which errors to throw. If the current behavior of grouped hatch is one color per dataset, than the behavior of hatch should also be one color per dataset. This is also consistent with stackplot. Also, that's the behavior you've documented:
Until you get better intuition for what would make a good issue, I strongly recommend you ask maintainers if a discussion warrants a stand alone issue before opening a new one.