Title: [Bug]: Nondeterministic behavior with subplot spacing and constrained layout · Issue #28574 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Nondeterministic behavior with subplot spacing and constrained layout · Issue #28574 · matplotlib/matplotlib
X Title: [Bug]: Nondeterministic behavior with subplot spacing and constrained layout · Issue #28574 · matplotlib/matplotlib
Description: Bug summary I'm trying to get constrained layout to remove all space between subplots when no artists should be preventing it. In this example I've set all necessary rc params accordingly and changed the axes limits to ensure the x-axis ...
Open Graph Description: Bug summary I'm trying to get constrained layout to remove all space between subplots when no artists should be preventing it. In this example I've set all necessary rc params accordingly and chang...
X Description: Bug summary I'm trying to get constrained layout to remove all space between subplots when no artists should be preventing it. In this example I've set all necessary rc params accordingly a...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/28574
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Nondeterministic behavior with subplot spacing and constrained layout","articleBody":"### Bug summary\r\n\r\nI'm trying to get constrained layout to remove all space between subplots when no artists should be preventing it. In this example I've set all necessary rc params accordingly and changed the axes limits to ensure the x-axis tick labels don't spill beyond the axis extent. The resulting space between the axes is nondeterministic.\r\n\r\n\r\n### Code for reproduction\r\n\r\n```Python\r\n%matplotlib inline\r\n\r\nimport matplotlib.pyplot as plt\r\nrc = {\r\n \"xtick.direction\": \"in\", \r\n \"ytick.direction\": \"in\",\r\n \"figure.constrained_layout.use\": True,\r\n \"figure.constrained_layout.h_pad\": 0,\r\n \"figure.constrained_layout.w_pad\": 0,\r\n \"figure.constrained_layout.wspace\": 0,\r\n \"figure.constrained_layout.hspace\": 0,\r\n \"axes.labelpad\": 0,\r\n}\r\n\r\nfor _ in range(2):\r\n with plt.style.context(rc):\r\n fig, axes = plt.subplots(1, 2, figsize=(6, 2), sharey=True)\r\n \r\n for ax in axes.flat:\r\n ax.set_xlim(-0.1, 1.1)\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nExample output (ran a handful of times until one of each result showed):\r\n\r\n\r\n### Expected outcome\r\n\r\nZero spacing between the axes, deterministically.\r\n\r\n### Additional information\r\n\r\nI noticed that the results became deterministic (with zero space between panels) when saving the figure (that is, the result that displayed in the notebook, not just the saved figure). Inserting a `fig.canvas.draw()` at the end likewise ensures zero space deterministically.\r\n\r\n### Operating system\r\n\r\nRocky Linux\r\n\r\n### Matplotlib Version\r\n\r\n3.9.1\r\n\r\n### Matplotlib Backend\r\n\r\ninline\r\n\r\n### Python version\r\n\r\n3.11.9\r\n\r\n### Jupyter version\r\n\r\n4.2.3\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/zachjweiner","@type":"Person","name":"zachjweiner"},"datePublished":"2024-07-14T17:39:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/28574/matplotlib/issues/28574"}
| 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:b82e896e-0c38-8c66-a681-5c95ceb6c7c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9832:117213:1D7A53A:27D6D96:6A5372FB |
| html-safe-nonce | 8ad1408c4aa3b9bab8041a90688db0d1b863ae0493a3f60ba8a703298fc58524 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODMyOjExNzIxMzoxRDdBNTNBOjI3RDZEOTY6NkE1MzcyRkIiLCJ2aXNpdG9yX2lkIjoiMjg3NDc0NTM2Mzg4OTM1MzQ2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c7ab292db2cbbcf466f4c85f1aefcf4e1da305722f7c8ad20ad1586157f94dac |
| hovercard-subject-tag | issue:2407529259 |
| 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/28574/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19f974bb9a593ace2fa6a253af9960274a554193fc85bcd0bea00e1b058851c6/matplotlib/matplotlib/issues/28574 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19f974bb9a593ace2fa6a253af9960274a554193fc85bcd0bea00e1b058851c6/matplotlib/matplotlib/issues/28574 |
| og:image:alt | Bug summary I'm trying to get constrained layout to remove all space between subplots when no artists should be preventing it. In this example I've set all necessary rc params accordingly and chang... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zachjweiner |
| 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