Title: [Bug]: Legend overlaps shaded area in fill_between with legend location "best" · Issue #27414 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Legend overlaps shaded area in fill_between with legend location "best" · Issue #27414 · matplotlib/matplotlib
X Title: [Bug]: Legend overlaps shaded area in fill_between with legend location "best" · Issue #27414 · matplotlib/matplotlib
Description: Bug summary When using the fill_between function in matplotlib with a legend and specifying the legend location as "best", the legend is not taking into account the shaded area and may overlap with it. Code for reproduction import matplo...
Open Graph Description: Bug summary When using the fill_between function in matplotlib with a legend and specifying the legend location as "best", the legend is not taking into account the shaded area and may overlap with...
X Description: Bug summary When using the fill_between function in matplotlib with a legend and specifying the legend location as "best", the legend is not taking into account the shaded area and may ov...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27414
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Legend overlaps shaded area in fill_between with legend location \"best\"","articleBody":"### Bug summary\n\nWhen using the `fill_between` function in matplotlib with a legend and specifying the legend location as \"best\", the legend is not taking into account the shaded area and may overlap with it.\r\n\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\n# Example data\r\nx = np.linspace(0, 5, 100)\r\ny1 = 0.5 * np.exp(x) - 1\r\ny2 = 2 * np.exp(x) + 1\r\n\r\n# Plotting shaded area\r\nplt.fill_between(x, y1, y2, color='gray', alpha=0.5, label='Shaded Area')\r\n\r\n# Set y-axis limit\r\nplt.ylim(-10, 100)\r\n\r\n# Adding legend with location \"best\"\r\nplt.legend(loc='best')\r\n\r\n# Show the plot\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\n\r\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows 11\n\n### Matplotlib Version\n\n3.8.0\n\n### Matplotlib Backend\n\nmodule://backend_interagg\n\n### Python version\n\nPython 3.11.5\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nconda","author":{"url":"https://github.com/mauroo4","@type":"Person","name":"mauroo4"},"datePublished":"2023-12-01T07:05:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/27414/matplotlib/issues/27414"}
| 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:e04a52dd-7f23-67d2-a921-7fbb0a973770 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CF66:264800:7A0E6:9A836:6A52BDD7 |
| html-safe-nonce | a27353be03ea36a856386e66d570e006ab596838175892c4b9688b82e05288b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjY2OjI2NDgwMDo3QTBFNjo5QTgzNjo2QTUyQkRENyIsInZpc2l0b3JfaWQiOiI0NzQzNTM3NDgzMjI0MTA0NDA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d12cee4d251bd1b96c052cac2949c19eddc70425c13e96f309bf22f68d2eb701 |
| hovercard-subject-tag | issue:2020247130 |
| 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/27414/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5444d226d376c2bd88dd227f3ae00630a452ab7821c13863228f48710927f805/matplotlib/matplotlib/issues/27414 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5444d226d376c2bd88dd227f3ae00630a452ab7821c13863228f48710927f805/matplotlib/matplotlib/issues/27414 |
| og:image:alt | Bug summary When using the fill_between function in matplotlib with a legend and specifying the legend location as "best", the legend is not taking into account the shaded area and may overlap with... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mauroo4 |
| 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