Title: [Bug]: stacked histogram does not properly handle edgecolor and hatches · Issue #26718 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: stacked histogram does not properly handle edgecolor and hatches · Issue #26718 · matplotlib/matplotlib
X Title: [Bug]: stacked histogram does not properly handle edgecolor and hatches · Issue #26718 · matplotlib/matplotlib
Description: Bug summary When using stacked histogram in matplotlib 3.7.2 the functionality of hatch and edgecolor is broken. It simply gives an error if trying to define either a separate edgecolor or hatch value for the stacked parts of the histogr...
Open Graph Description: Bug summary When using stacked histogram in matplotlib 3.7.2 the functionality of hatch and edgecolor is broken. It simply gives an error if trying to define either a separate edgecolor or hatch va...
X Description: Bug summary When using stacked histogram in matplotlib 3.7.2 the functionality of hatch and edgecolor is broken. It simply gives an error if trying to define either a separate edgecolor or hatch va...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26718
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: stacked histogram does not properly handle edgecolor and hatches","articleBody":"### Bug summary\r\n\r\nWhen using stacked histogram in matplotlib 3.7.2 the functionality of hatch and edgecolor is broken. It simply gives an error if trying to define either a separate edgecolor or hatch value for the stacked parts of the histogram.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nplt.hist([np.random.uniform(size=100), np.random.uniform(size=50)],\r\n stacked=True,\r\n color=[\"C0\", \"C1\"],\r\n edgecolor='black',\r\n hatch=[\"/\", \".\"],\r\n linewidth=1,\r\n fill=True,\r\n density=False, \r\n )\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n\u003e Traceback (most recent call last):\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3460, in run_code\r\n\u003e exec(code_obj, self.user_global_ns, self.user_ns)\r\n\u003e File \"\u003cipython-input-11-3f15e200502a\u003e\", line 1, in \u003cmodule\u003e\r\n\u003e plt.hist([np.random.uniform(size=100), np.random.uniform(size=50)],\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/pyplot.py\", line 2645, in hist\r\n\u003e return gca().hist(\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/__init__.py\", line 1446, in inner\r\n\u003e return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/axes/_axes.py\", line 6944, in hist\r\n\u003e p._internal_update(kwargs)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/artist.py\", line 1223, in _internal_update\r\n\u003e return self._update_props(\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/artist.py\", line 1199, in _update_props\r\n\u003e ret.append(func(v))\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/patches.py\", line 525, in set_hatch\r\n\u003e mhatch._validate_hatch_pattern(hatch)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/hatch.py\", line 188, in _validate_hatch_pattern\r\n\u003e invalids = ''.join(sorted(invalids))\r\n\u003e TypeError: sequence item 0: expected str instance, NoneType found\r\n\r\n\r\nWhile using different edgecolors for the stacked part with \r\n\r\n```\r\nplt.hist([np.random.uniform(size=100), np.random.uniform(size=50)],\r\n stacked=True,\r\n color=[\"C0\", \"C1\"],\r\n edgecolor=[\"C2\", \"C3\"],\r\n hatch=\"/\",\r\n linewidth=1,\r\n fill=True,\r\n density=False, \r\n )\r\n```\r\n\r\ndelivers the error\r\n\r\n\u003e Traceback (most recent call last):\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/IPython/core/interactiveshell.py\", line 3460, in run_code\r\n\u003e exec(code_obj, self.user_global_ns, self.user_ns)\r\n\u003e File \"\u003cipython-input-16-4bdbf23ac913\u003e\", line 1, in \u003cmodule\u003e\r\n\u003e plt.hist([np.random.uniform(size=100), np.random.uniform(size=50)],\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/pyplot.py\", line 2645, in hist\r\n\u003e return gca().hist(\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/__init__.py\", line 1446, in inner\r\n\u003e return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/axes/_axes.py\", line 6944, in hist\r\n\u003e p._internal_update(kwargs)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/artist.py\", line 1223, in _internal_update\r\n\u003e return self._update_props(\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/artist.py\", line 1199, in _update_props\r\n\u003e ret.append(func(v))\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/patches.py\", line 341, in set_edgecolor\r\n\u003e self._set_edgecolor(color)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/patches.py\", line 327, in _set_edgecolor\r\n\u003e self._edgecolor = colors.to_rgba(color, self._alpha)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/colors.py\", line 299, in to_rgba\r\n\u003e rgba = _to_rgba_no_colorcycle(c, alpha)\r\n\u003e File \"/opt/anaconda3/envs/code/lib/python3.10/site-packages/matplotlib/colors.py\", line 383, in _to_rgba_no_colorcycle\r\n\u003e raise ValueError(\"RGBA sequence should have length 3 or 4\")\r\n\u003e ValueError: RGBA sequence should have length 3 or 4\r\n\r\nIt seems to interpret the list of `edgecolor` [\"C2\", \"C3\"] as one color, although it is able to manage similar input for `color`.\r\n\r\n### Expected outcome\r\n\r\nIt should look similar to the following example, except that the top orange part should have dots and not slanted lines:\r\n\r\nThe code used to generate this plot:\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\nplt.hist([np.random.uniform(size=100), np.random.uniform(size=50)],\r\n stacked=True,\r\n color=[\"C0\", \"C1\"],\r\n edgecolor='black',\r\n hatch=\"/\",\r\n linewidth=1,\r\n fill=True,\r\n density=False, \r\n )\r\n```\r\n\r\nIn case of the second example it should habe two different edgecolors for the first and second part of the stacked histogram.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\nMacOSX\r\n\r\n### Matplotlib Version\r\n\r\n3.7.2\r\n\r\n### Matplotlib Backend\r\n\r\nMacOSX\r\n\r\n### Python version\r\n\r\n3.10.0\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/marcelernst","@type":"Person","name":"marcelernst"},"datePublished":"2023-09-07T21:11:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/26718/matplotlib/issues/26718"}
| 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:68f8b8c3-00cd-3280-d109-a28010b04b83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9F4:228F1C:2C791F:3AD1C6:6A52EB9A |
| html-safe-nonce | 44bcf18fe14b3d48e8a974bc19034bf58eff783ab0e0b7d3774d4b9ee1fffe40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUY0OjIyOEYxQzoyQzc5MUY6M0FEMUM2OjZBNTJFQjlBIiwidmlzaXRvcl9pZCI6IjkwODM4NTEyNTg2ODM2NDg5MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 75b17d1889e7fccfb7007d865489f0758438aacbb5b2936e6ecedbd50c8a79e6 |
| hovercard-subject-tag | issue:1886568974 |
| 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/26718/issue_layout |
| twitter:image | https://opengraph.githubassets.com/87997ebd2d966f0f801bdd4712146721d6e37bd7e94a78e878d59c406b0cc74a/matplotlib/matplotlib/issues/26718 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/87997ebd2d966f0f801bdd4712146721d6e37bd7e94a78e878d59c406b0cc74a/matplotlib/matplotlib/issues/26718 |
| og:image:alt | Bug summary When using stacked histogram in matplotlib 3.7.2 the functionality of hatch and edgecolor is broken. It simply gives an error if trying to define either a separate edgecolor or hatch va... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | marcelernst |
| 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