Title: Setting alpha on legend handle changes patch color · Issue #11702 · matplotlib/matplotlib · GitHub
Open Graph Title: Setting alpha on legend handle changes patch color · Issue #11702 · matplotlib/matplotlib
X Title: Setting alpha on legend handle changes patch color · Issue #11702 · matplotlib/matplotlib
Description: Bug report Bug summary I occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend. However, when I call set_alpha on a legend handle, the color of the patch in th...
Open Graph Description: Bug report Bug summary I occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend. However, when I call set_alpha on a leg...
X Description: Bug report Bug summary I occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend. However, when I call set_alpha on a...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11702
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Setting alpha on legend handle changes patch color","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nI occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend. However, when I call `set_alpha` on a legend handle, the color of the patch in the legend changes.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.hist([1, 2, 3], alpha = 0.25, label = 'data', color = 'red')\r\nlegend = plt.legend()\r\nfor lh in legend.legendHandles:\r\n lh.set_alpha(1.0)\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n\r\n**Work-around**\r\n\r\nI can get the result I desire if I call `set_edgecolor()` and `set_facecolor()`:\r\n\r\n```python\r\nplt.hist([1, 2, 3], alpha = 0.25, label = 'data', color = 'red')\r\nlegend = plt.legend()\r\nfor lh in legend.legendHandles:\r\n lh.set_facecolor(lh.get_facecolor())\r\n lh.set_edgecolor(lh.get_edgecolor())\r\n lh.set_alpha(1.0)\r\n```\r\n\r\n**Expected outcome**\r\n\r\n\r\n\r\n**Matplotlib version**\r\n- Matplotlib v2.2.2\r\n- Installed from Anaconda (default channel)\r\n- Backend: module://ipykernel.pylab.backend_inline\r\n- Jupyter version: 5.5.0\r\n\r\n\r\n","author":{"url":"https://github.com/bpteague","@type":"Person","name":"bpteague"},"datePublished":"2018-07-19T01:41:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/11702/matplotlib/issues/11702"}
| 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:2e79d5c5-d3e8-4749-85f4-961586c767a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7AC:2D4C4C:14C42:1B611:6A532823 |
| html-safe-nonce | 809b987e735984a038e6795ab0a6fa2dba8f1319ec52a309ec27efc060d848ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0FDOjJENEM0QzoxNEM0MjoxQjYxMTo2QTUzMjgyMyIsInZpc2l0b3JfaWQiOiIxMjMzMDkzMDU4MTU0OTMyMjU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d3d3f24573c1bb6e09a7d681051d78ca5ee003eafa7d399b66e66b16eec9783b |
| hovercard-subject-tag | issue:342548873 |
| 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/11702/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3a6f26de2189e71f915a0df3579e11b241a49e48538019eca16bf9941fba2115/matplotlib/matplotlib/issues/11702 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3a6f26de2189e71f915a0df3579e11b241a49e48538019eca16bf9941fba2115/matplotlib/matplotlib/issues/11702 |
| og:image:alt | Bug report Bug summary I occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend. However, when I call set_alpha on a leg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bpteague |
| 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