Title: [Bug]: Global legend weird behaviors · Issue #26841 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Global legend weird behaviors · Issue #26841 · matplotlib/matplotlib
X Title: [Bug]: Global legend weird behaviors · Issue #26841 · matplotlib/matplotlib
Description: Bug summary The color of the global legend for all subplots does not match the label colors. Code for reproduction esbs = np.array(list(range(0,41))) lines = [e for e in asrs] colors = ['dodgerblue', 'tomato', 'yellowgreen', 'orange', 'd...
Open Graph Description: Bug summary The color of the global legend for all subplots does not match the label colors. Code for reproduction esbs = np.array(list(range(0,41))) lines = [e for e in asrs] colors = ['dodgerblue...
X Description: Bug summary The color of the global legend for all subplots does not match the label colors. Code for reproduction esbs = np.array(list(range(0,41))) lines = [e for e in asrs] colors = ['dodger...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/26841
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Global legend weird behaviors","articleBody":"### Bug summary\r\n\r\nThe color of the global legend for all subplots does not match the label colors.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nesbs = np.array(list(range(0,41)))\r\nlines = [e for e in asrs]\r\n\r\ncolors = ['dodgerblue', 'tomato', 'yellowgreen', 'orange', 'dodgerblue', 'tomato', 'yellowgreen', 'orange']\r\nlabels = ['A', 'C', 'M','F','A+', 'C+', 'M+','F+',]\r\nlinestyles = ['-', '-','-', '-','--','--','--', '--']\r\n\r\nfig, axs = plt.subplots(2, figsize=(6, 6), sharex=False)\r\n\r\nhandles = []\r\nfor i in range(8):\r\n print(i, colors[i], labels[i])\r\n if i == 3 or i == 7:\r\n h = axs[1].plot(esbs, lines[i], color=colors[i], linewidth=1.2, linestyle=linestyles[i], label=labels[i])\r\n else:\r\n h = axs[0].plot(esbs, lines[i], color=colors[i], linewidth=1.2, linestyle=linestyles[i], label=labels[i])\r\n handles.append(h)\r\n\r\nfig.legend(handles, labels=labels, ncol=2, bbox_to_anchor=(0.15, 1.06), loc='upper left')\r\n\r\nplt.show()\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n\u003cimg width=\"440\" alt=\"image\" src=\"https://github.com/matplotlib/matplotlib/assets/93981430/704d3f9b-9f06-444c-bed6-bef88bae54b9\"\u003e\r\n\r\n\r\n### Expected outcome\r\n\r\nThe colors for legend F and legend F+ should be orange. But they are different.\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Matplotlib Version\r\n\r\n3.7.1\r\n\r\n### Matplotlib Backend\r\n\r\n_No response_\r\n\r\n### Python version\r\n\r\n_No response_\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nNone","author":{"url":"https://github.com/imxtx","@type":"Person","name":"imxtx"},"datePublished":"2023-09-20T12:42:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/26841/matplotlib/issues/26841"}
| 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:f44504b5-12db-1294-a572-5600c99db257 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4FE:153FD3:CAC166:10FB959:6A5321C4 |
| html-safe-nonce | 5871d93a08e75319c2877c3702d2ad2ea6da91c47b963e7933e633ce1f2c1155 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEZFOjE1M0ZEMzpDQUMxNjY6MTBGQjk1OTo2QTUzMjFDNCIsInZpc2l0b3JfaWQiOiIzMTgzMzQyNTkwOTIyNzkzNDEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 36a1f96bdf740537aba4acebcafa4ba351784ad7d22b6dd51813d43996668b9f |
| hovercard-subject-tag | issue:1904912758 |
| 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/26841/issue_layout |
| twitter:image | https://opengraph.githubassets.com/15caa3482312f46ee439f88f0986847944c0f06c4ea812b16cbfdca1727c58d2/matplotlib/matplotlib/issues/26841 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/15caa3482312f46ee439f88f0986847944c0f06c4ea812b16cbfdca1727c58d2/matplotlib/matplotlib/issues/26841 |
| og:image:alt | Bug summary The color of the global legend for all subplots does not match the label colors. Code for reproduction esbs = np.array(list(range(0,41))) lines = [e for e in asrs] colors = ['dodgerblue... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | imxtx |
| 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