Title: [MNT]: Discussion : Normalize hatch patterns per dataset instead of per patch in grouped_bar · Issue #30789 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: Discussion : Normalize hatch patterns per dataset instead of per patch in grouped_bar · Issue #30789 · matplotlib/matplotlib
X Title: [MNT]: Discussion : Normalize hatch patterns per dataset instead of per patch in grouped_bar · Issue #30789 · matplotlib/matplotlib
Description: Summary The current implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset produces multiple patches. This causes hatch patterns to repeat incorrectly within a dataset. Proposed fix Replac...
Open Graph Description: Summary The current implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset produces multiple patches. This causes hatch patterns to repeat incorrect...
X Description: Summary The current implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset produces multiple patches. This causes hatch patterns to repeat incorrect...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30789
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: Discussion : Normalize hatch patterns per dataset instead of per patch in grouped_bar","articleBody":"### Summary\n\nThe current implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset produces multiple patches. This causes hatch patterns to repeat incorrectly within a dataset.\n\n### Proposed fix\n\nReplace the patch-level hatch cycling with dataset-level normalization.\nSpecifically:\nDetermine the number of datasets (num_datasets = len(heights)),\nNormalize hatch to one pattern per dataset,\nApply that hatch consistently to all patches belonging to the same dataset.\nThis aligns hatch behavior with existing color/label broadcasting in grouped_bar and resolves the test failures caused by per-patch cycling.\n\n```\n# Normalize hatches: one hatch per dataset (no per-patch cycling)\nnum_datasets = len(heights)\nuser_hatch = kwargs.get(\"hatch\", None)\n\nif user_hatch is None:\n # No hatch specified → all datasets get None\n hatches = [None] * num_datasets\nelse:\n # Ensure list-like\n if isinstance(user_hatch, str):\n raise TypeError(\"hatch must be a list-like of strings, not a single string\")\n\n try:\n hatch_list = list(user_hatch)\n except TypeError:\n raise TypeError(\"hatch must be list-like\")\n\n if len(hatch_list) \u003c num_datasets:\n raise ValueError(\n f\"Expected at least {num_datasets} hatch patterns for {num_datasets} datasets\"\n )\n\n # Use exactly one hatch per dataset\n hatches = hatch_list[:num_datasets]\n\n# Iterator used by the bar-creation loop\nhatches = iter(hatches)\n```\n","author":{"url":"https://github.com/ilakkmanoharan","@type":"Person","name":"ilakkmanoharan"},"datePublished":"2025-11-25T13:25:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/30789/matplotlib/issues/30789"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8ab363c2-03f0-c9ce-0811-01e1dbf9f8da |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BEC:C1E1E:9661A3:CA100B:6A527A15 |
| html-safe-nonce | a85bcde43799ee02028d3e6b2434168e88ce76e3b2d85e3cbe25772b6b317bad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkVDOkMxRTFFOjk2NjFBMzpDQTEwMEI6NkE1MjdBMTUiLCJ2aXNpdG9yX2lkIjoiNDU5OTAyMzUxNjAyNDczMjE4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9649cbf75b51c53fe008f6f54dea70b052e2c6853a34f870cf8f3a50dd5af212 |
| hovercard-subject-tag | issue:3663072290 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/30789/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1686b521dddab894a1e12ae7692a4333cc9f7a1cc2ab1db22fa000c075f34b75/matplotlib/matplotlib/issues/30789 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1686b521dddab894a1e12ae7692a4333cc9f7a1cc2ab1db22fa000c075f34b75/matplotlib/matplotlib/issues/30789 |
| og:image:alt | Summary The current implementation cycles hatch patterns per patch, which breaks grouped bar semantics because each dataset produces multiple patches. This causes hatch patterns to repeat incorrect... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilakkmanoharan |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width