Title: [Bug]: tight_layout (version 3.5+) · Issue #22673 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: tight_layout (version 3.5+) · Issue #22673 · matplotlib/matplotlib
X Title: [Bug]: tight_layout (version 3.5+) · Issue #22673 · matplotlib/matplotlib
Description: Bug summary fig.tight_layout is broken in current matplotlib. Code for reproduction %pylab plot([0,1]) tight_layout() # happens same way in object mode from matplotlib import pylab as plt fig, ax = plt.subplots() ax.plot([0,1]) fig.tight...
Open Graph Description: Bug summary fig.tight_layout is broken in current matplotlib. Code for reproduction %pylab plot([0,1]) tight_layout() # happens same way in object mode from matplotlib import pylab as plt fig, ax =...
X Description: Bug summary fig.tight_layout is broken in current matplotlib. Code for reproduction %pylab plot([0,1]) tight_layout() # happens same way in object mode from matplotlib import pylab as plt fig, ax =...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22673
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: tight_layout (version 3.5+)","articleBody":"### Bug summary\n\nfig.tight_layout is broken in current matplotlib.\n\n### Code for reproduction\n\n```python\n%pylab\r\nplot([0,1])\r\ntight_layout()\r\n\r\n# happens same way in object mode\r\nfrom matplotlib import pylab as plt\r\nfig, ax = plt.subplots()\r\nax.plot([0,1])\r\nfig.tight_layout()\n```\n\n\n### Actual outcome\n\n\r\n\r\nbelow another example from real code that may be instructive\r\n\r\n\n\n### Expected outcome\n\nfigure scaled to image size, background deleted.\n\n### Additional information\n\nHappens always.\r\n\r\nI do not recall this issue in version before 3.5\r\n\r\nI have no clue why it is happening. The flaw seems to lay in mpl getting/setting wrong window size when using tight_layout. Maybe gtk unhappy with X11. When I use `mpl.use('Qt5Cairo')` then it just makes the window *and fonts* smaller. Obviously, `tight_layout` should not change physical window size on screen! Similar for Gtk4Cairo. `Gtk4Agg` has similar issues to `Qt5Agg` but does not retain noise in background, just shrinks figure. I could be related to DPI settings. It might get them from a different system call than when opening the window? \r\n\r\nThe only fix I can find is use other plot package, e.g., plotly.\n\n### Operating system\n\nLinux 5.16.14-200.fc35.x86_64 #1 SMP PREEMPT Fri Mar 11 20:31:18 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\nQt5Agg\n\n### Python version\n\nPython 3.10.2\n\n### Jupyter version\n\nN/A\n\n### Installation\n\npip","author":{"url":"https://github.com/2sn","@type":"Person","name":"2sn"},"datePublished":"2022-03-20T07:31:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":76},"url":"https://github.com/22673/matplotlib/issues/22673"}
| 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:0fb9a1ed-2ef4-f2c4-bb34-4e676dbff8e2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 979E:163D9C:14A80C3:1B3DFA7:6A51B917 |
| html-safe-nonce | db12b2aea4cc905b76670262f255b276612f98e9b3fe0f2da20050b4860aefc9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzlFOjE2M0Q5QzoxNEE4MEMzOjFCM0RGQTc6NkE1MUI5MTciLCJ2aXNpdG9yX2lkIjoiOTA0MDA2MjE2NDQzMDMzODMyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 319c3a211e7978a9d6cb4e4580c20b4b67a478d0389be4a3525ffc0026d015a6 |
| hovercard-subject-tag | issue:1174462883 |
| 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/22673/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6c26644107451b25bc82e0278a385defb70be70e2638717a61855a9657d7db8b/matplotlib/matplotlib/issues/22673 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6c26644107451b25bc82e0278a385defb70be70e2638717a61855a9657d7db8b/matplotlib/matplotlib/issues/22673 |
| og:image:alt | Bug summary fig.tight_layout is broken in current matplotlib. Code for reproduction %pylab plot([0,1]) tight_layout() # happens same way in object mode from matplotlib import pylab as plt fig, ax =... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 2sn |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width