Title: [Bug]: Regression: Setting alpha on legend handle changes patch color · Issue #21966 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Regression: Setting alpha on legend handle changes patch color · Issue #21966 · matplotlib/matplotlib
X Title: [Bug]: Regression: Setting alpha on legend handle changes patch color · Issue #21966 · matplotlib/matplotlib
Description: Bug summary Bug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot. Code for reproduction import matplotlib.pyplot as plt import pandas as pd ...
Open Graph Description: Bug summary Bug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot. Code for reproduction import matpl...
X Description: Bug summary Bug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot. Code for reproduction import matpl...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21966
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Regression: Setting alpha on legend handle changes patch color","articleBody":"### Bug summary\n\nBug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot.\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nimport pandas as pd\r\n\r\ndf = pd.DataFrame({\r\n 'sales': [3, 2, 3],\r\n 'visits': [20, 42, 28],\r\n 'day': [1, 2, 3],\r\n})\r\n\r\ndf.plot.area(x='day')\r\nlegend = plt.legend()\r\nfor p in legend.get_patches():\r\n p.set_alpha(1)\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\nThe patch for 'visits' should be orange.\n\n### Additional information\n\nThis was working fine at least until mpl 3.3.4.\r\n\r\nAs for the previous workaround, calling set_facecolor(get_facecolor()) before calling set_alpha() works. I'm using legend.get_patches() here instead of iterating through the handles directly, but there's no difference.\n\n### Operating system\n\nLinux (debian unstable)\n\n### Matplotlib Version\n\n3.5.0\n\n### Matplotlib Backend\n\nQt5Agg or agg\n\n### Python version\n\n3.9.9\n\n### Jupyter version\n\nn/a\n\n### Installation\n\nLinux package manager","author":{"url":"https://github.com/wavexx","@type":"Person","name":"wavexx"},"datePublished":"2021-12-15T16:49:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/21966/matplotlib/issues/21966"}
| 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:2d5586b7-65d7-a6b5-98f0-a5bc88b98f06 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7DE:15E3B:3280FE5:44C9A98:6A53EE1F |
| html-safe-nonce | ee6cc69bff669c68efbad0782a4a54e68bd5826196540b1cb1b1c3e2b0954c67 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0RFOjE1RTNCOjMyODBGRTU6NDRDOUE5ODo2QTUzRUUxRiIsInZpc2l0b3JfaWQiOiI0NDk3NTQ3Nzk2ODk2MDE3OTUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7bb062c812f9fdaf3f69c3b487c2193598f22cf0e3eb3e485e29c71fac38df6e |
| hovercard-subject-tag | issue:1081262421 |
| 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/21966/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9a9f08055e6a2a6abd9b041e53db87908be92390a8bbfa5936c1b6e14d17fe89/matplotlib/matplotlib/issues/21966 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9a9f08055e6a2a6abd9b041e53db87908be92390a8bbfa5936c1b6e14d17fe89/matplotlib/matplotlib/issues/21966 |
| og:image:alt | Bug summary Bug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot. Code for reproduction import matpl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wavexx |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width