Title: Figure legend not keeping Line2D marker · Issue #9155 · matplotlib/matplotlib · GitHub
Open Graph Title: Figure legend not keeping Line2D marker · Issue #9155 · matplotlib/matplotlib
X Title: Figure legend not keeping Line2D marker · Issue #9155 · matplotlib/matplotlib
Description: Bug report Bug summary When retrieving handles used in legend, marker property is not kept. Code for reproduction import matplotlib.pyplot as plt point = plt.Line2D([1],[1], marker='o') legend = plt.gcf().legend(handles=[point], labels=[...
Open Graph Description: Bug report Bug summary When retrieving handles used in legend, marker property is not kept. Code for reproduction import matplotlib.pyplot as plt point = plt.Line2D([1],[1], marker='o') legend = pl...
X Description: Bug report Bug summary When retrieving handles used in legend, marker property is not kept. Code for reproduction import matplotlib.pyplot as plt point = plt.Line2D([1],[1], marker='o') leg...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9155
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Figure legend not keeping Line2D marker","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\nWhen retrieving handles used in legend, `marker` property is not kept.\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\npoint = plt.Line2D([1],[1], marker='o')\r\nlegend = plt.gcf().legend(handles=[point], labels=['point'])\r\n\r\n# First way\r\nhandles = legend.legendHandles\r\nhandles[0].get_marker()\r\n# Second way\r\nlines= legend.get_lines()\r\nlines[0].get_marker()\r\n```\r\n**Actual outcome**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nOut[1]: ''\r\n```\r\n\r\n**Expected outcome**\r\nWhen plotting an `Axes` legend, `get_legend_handles_labels()` can be used, which does return the right marker. There isn't such a method in `Figure`, so when using `Legend` methods or properties such as `legend.get_lines()` or `legend.legendHandles`, line2D marker isn't kept.\r\n\r\nIs there a better way of retrieving handles from a legend?\r\nAm I doing something wrong?\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating System: Windows 10\r\n * Matplotlib Version: 2.0.2\r\n * Python Version: 3.6.1\r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\ncc @juanlu001","author":{"url":"https://github.com/anhiga","@type":"Person","name":"anhiga"},"datePublished":"2017-09-04T14:45:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/9155/matplotlib/issues/9155"}
| 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:56c7c87a-7363-db49-5d35-102d1c380f94 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 913A:133662:5567E2:73B630:6A527C20 |
| html-safe-nonce | 28e8223e2b26b477e60cd12bcf0725b033553c89e4b7ed47c5b6bb538e7ce942 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTNBOjEzMzY2Mjo1NTY3RTI6NzNCNjMwOjZBNTI3QzIwIiwidmlzaXRvcl9pZCI6IjM0MzQ2NDQyNjE2MTIwODM1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 93870f2653a24efee8b97be4274e62fec7331480c0f7585c9e3a4aa585d3c562 |
| hovercard-subject-tag | issue:255062230 |
| 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/9155/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79e8f599a7c34e88d984cb53a6b233b79269d688c56e97877e9aab3182a327e9/matplotlib/matplotlib/issues/9155 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79e8f599a7c34e88d984cb53a6b233b79269d688c56e97877e9aab3182a327e9/matplotlib/matplotlib/issues/9155 |
| og:image:alt | Bug report Bug summary When retrieving handles used in legend, marker property is not kept. Code for reproduction import matplotlib.pyplot as plt point = plt.Line2D([1],[1], marker='o') legend = pl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anhiga |
| 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