Title: Using edgecolors='face' with stackplot causes value error when using plt.legend() · Issue #20258 · matplotlib/matplotlib · GitHub
Open Graph Title: Using edgecolors='face' with stackplot causes value error when using plt.legend() · Issue #20258 · matplotlib/matplotlib
X Title: Using edgecolors='face' with stackplot causes value error when using plt.legend() · Issue #20258 · matplotlib/matplotlib
Description: Bug report I was making a stack plot and wanted the edge colors of the plotted lines to be the same as the fill color instead of the default white, so I set edgecolor='face'. This produces a value error when using plt.legend(). Without t...
Open Graph Description: Bug report I was making a stack plot and wanted the edge colors of the plotted lines to be the same as the fill color instead of the default white, so I set edgecolor='face'. This produces a value ...
X Description: Bug report I was making a stack plot and wanted the edge colors of the plotted lines to be the same as the fill color instead of the default white, so I set edgecolor='face'. This produces ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20258
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using edgecolors='face' with stackplot causes value error when using plt.legend()","articleBody":"### Bug report\r\n\r\nI was making a stack plot and wanted the edge colors of the plotted lines to be the same as the fill color instead of the default white, so I set edgecolor='face'. This produces a value error when using plt.legend(). Without the legend function, there are no errors and it plots as expected. I tried changing different parameters of the legend() function, but didn't have any success.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport numpy as np\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\n# Create a dataset\r\nmy_count = [\r\n \"France\", \"Australia\", \"Japan\", \"USA\", \"Germany\",\r\n \"Congo\", \"China\", \"England\", \"Spain\", \"Greece\",\r\n \"Marocco\", \"South Africa\", \"Indonesia\", \"Peru\", \"Chili\", \"Brazil\"\r\n]\r\ndf = pd.DataFrame(\r\n {\r\n \"country\": np.repeat(my_count, 10),\r\n \"years\": list(range(2000, 2010)) * 16,\r\n \"value\": np.random.rand(160)\r\n }\r\n)\r\npivot = df.groupby([\"country\", \"years\"])[\"value\"].sum().unstack(0).cumsum()\r\n# Plot dataset\r\nplt.stackplot(\r\n pivot.index.values,\r\n pivot.T.values,\r\n labels=pivot.columns,\r\n alpha=0.2,\r\n edgecolors=\"face\"\r\n)\r\nplt.legend()\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\nwith the following value error:\r\n\r\n```\r\nValueError: Using a string of single character colors as a color sequence is not supported. The colors can be passed as an explicit list instead.\r\n```\r\n\r\n**Expected outcome**\r\n\r\nThe same graph as above, but with a legend.\r\n\r\n**Matplotlib version**\r\n * Operating system: Microsoft Windows 10\r\n * Matplotlib version: 3.4.2 \r\n * Matplotlib backend: module://ipykernel.pylab.backend_inline \r\n * Python version: 3.8.5\r\n * Other libraries: numpy, pandas (to create dataset)\r\n\r\nInstalled matplotlib using 'pip install matplotlib'.\r\n\r\n","author":{"url":"https://github.com/Stratton19","@type":"Person","name":"Stratton19"},"datePublished":"2021-05-18T20:03:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/20258/matplotlib/issues/20258"}
| 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:cb705f74-716f-bb3f-ed1b-a45667ef00f0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D750:25B817:7E7E48:B29EFE:6A510643 |
| html-safe-nonce | 9136b326c9b8aec17d762e7f4e1b0c918a3f42b30a91d771ced7aefd5c7dc443 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzUwOjI1QjgxNzo3RTdFNDg6QjI5RUZFOjZBNTEwNjQzIiwidmlzaXRvcl9pZCI6IjMyMzY0MzIxMjMzMjI3NjI4MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a3967fc6c816f8b97402f8f0d1534889aa15a3c239aaa88042aa8d9a2ec3263b |
| hovercard-subject-tag | issue:894733118 |
| 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/20258/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a5c61959ce4273ac86717002cd62e2c222ff5bd0ce363f8c730c584b5eefb0a/matplotlib/matplotlib/issues/20258 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a5c61959ce4273ac86717002cd62e2c222ff5bd0ce363f8c730c584b5eefb0a/matplotlib/matplotlib/issues/20258 |
| og:image:alt | Bug report I was making a stack plot and wanted the edge colors of the plotted lines to be the same as the fill color instead of the default white, so I set edgecolor='face'. This produces a value ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Stratton19 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 38906a4da4e3e9fd88dfeacee232f5932c0c5f7495de3b4efc53ddfac7173d12 |
| 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 | 90441ea9b98e7491aa6ebcd135fccce4e2396f48 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width