Title: Legend positioning behavior change from matplotlib {2.1.0 -> 2.2.2} · Issue #11126 · matplotlib/matplotlib · GitHub
Open Graph Title: Legend positioning behavior change from matplotlib {2.1.0 -> 2.2.2} · Issue #11126 · matplotlib/matplotlib
X Title: Legend positioning behavior change from matplotlib {2.1.0 -> 2.2.2} · Issue #11126 · matplotlib/matplotlib
Description: Bug report Bug summary The behavior of positioning a legend outside the plot by using the figure transformation(fig.transFigure) has changed, by shortening the size of plot and leaving too much space between plot and legend. Code for rep...
Open Graph Description: Bug report Bug summary The behavior of positioning a legend outside the plot by using the figure transformation(fig.transFigure) has changed, by shortening the size of plot and leaving too much spa...
X Description: Bug report Bug summary The behavior of positioning a legend outside the plot by using the figure transformation(fig.transFigure) has changed, by shortening the size of plot and leaving too much spa...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11126
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Legend positioning behavior change from matplotlib {2.1.0 -\u003e 2.2.2}","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\nThe behavior of positioning a legend outside the plot by using the figure transformation(**fig.transFigure**) has changed, by shortening the size of plot and leaving too much space between plot and legend.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\n# Fixing random state for reproducibility\r\nnp.random.seed(19680801)\r\n\r\nN = 50\r\nx = 15*np.random.rand(N)\r\ny = 15*np.random.rand(N)\r\ncolors = np.random.rand(N)\r\n\r\nfig, ax = plt.subplots(figsize=(8,6))\r\n\r\nax.scatter(x, y, c=colors, alpha=0.5, label='Scatter plot')\r\nax.plot([0, 15],[0, 15], color='r', linestyle='-', linewidth=2.5, label = 'Straight line')\r\n\r\nax.legend(bbox_to_anchor=(1, 0), loc=\"upper right\",\r\n bbox_transform=fig.transFigure, columnspacing=0.5, ncol=2)\r\n\r\nfig.tight_layout()\r\nplt.savefig(_image_name_, bbox_inches=\"tight\")\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n**Expected outcome**\r\nNotice the empty space between plot and the legend. This was not the case with Matplotlib version: 2.1.0\r\nBelow are the plots for the same stuff in both the versions:\r\nMatplotlib 2.1.0:\r\n\r\n\r\nMatplotb 2.2.2:\r\n\r\n\r\n**Matplotlib version**\r\n * Operating system: Windows 10\r\n * Matplotlib version: '2.2.2'\r\n * Matplotlib backend: Qt5Agg or module://ipykernel.pylab.backend_inline\r\n * Python version: Python 3.6.5 |Anaconda custom (64-bit)\r\n * Jupyter Notebook version: 6.3.1\r\n\r\nI have the Python installed through Anaconda and I spotted the above change after I updated my packages through Anaconda.\r\n","author":{"url":"https://github.com/deepak18","@type":"Person","name":"deepak18"},"datePublished":"2018-04-25T13:40:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/11126/matplotlib/issues/11126"}
| 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:2a993176-f198-98bb-108f-58b21aea4153 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD22:2E411E:2372B99:301F463:6A539AA6 |
| html-safe-nonce | 97d34b7a561afd75d21a5e9c91c1c2014e1c7291cdaadabbe070550870052468 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDIyOjJFNDExRToyMzcyQjk5OjMwMUY0NjM6NkE1MzlBQTYiLCJ2aXNpdG9yX2lkIjoiMTg1ODUyOTA4OTQ4MTM0NTY2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1c8b1f6101cb36720aece783dcc501d03d8cc953b55789e31e99f5cb5c979b9e |
| hovercard-subject-tag | issue:317632910 |
| 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/11126/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9ca49916190951335bae3e075500ea41964acfed11e9bf747590194f2eb406e/matplotlib/matplotlib/issues/11126 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9ca49916190951335bae3e075500ea41964acfed11e9bf747590194f2eb406e/matplotlib/matplotlib/issues/11126 |
| og:image:alt | Bug report Bug summary The behavior of positioning a legend outside the plot by using the figure transformation(fig.transFigure) has changed, by shortening the size of plot and leaving too much spa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | deepak18 |
| 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