Title: FIX: tight_layout having negative width axes by jklymak · Pull Request #10915 · matplotlib/matplotlib · GitHub
Open Graph Title: FIX: tight_layout having negative width axes by jklymak · Pull Request #10915 · matplotlib/matplotlib
X Title: FIX: tight_layout having negative width axes by jklymak · Pull Request #10915 · matplotlib/matplotlib
Description: PR Summary Closes #4413 #8062 fig.tight_layout() could cause axes to flip sign if the title was too big, and cause the whole thing to Error if the title was really big. This PR adds a check that the axes width and height is still greater than zero after the margins have been set. It would be nice to just collapse the axes when this happens, but thats actually a bit of work to fake because subplots_adjust 's space parameter is specified as a fraction of average axes width (not the way I'd have expressed this parameter, but...) Discussion in #4413 suggested that something could be done to ignore the title, but otherwise compute the tight_layout. I think that's theoretically possible, but if someone has a really long title they should probably shorten it or adjust the spacing manually rather than trying to make tight_layout do something magical. import matplotlib.pyplot as plt fig, axs = plt.subplots(1, 2, figsize=(6,2)) leng = 95 axs[0].set_title('A'+('a' * leng)) axs[0].set_yticks([]) axs[1].set_title('B' +('b' * leng)) axs[1].set_yticks([]) axs[0].set_xlabel('title length %d' % leng) fig.tight_layout() plt.show() For the second and third plots, a warning is emitted... PR Checklist Has Pytest style unit tests Code is PEP 8 compliant
Open Graph Description: PR Summary Closes #4413 #8062 fig.tight_layout() could cause axes to flip sign if the title was too big, and cause the whole thing to Error if the title was really big. This PR adds a check that t...
X Description: PR Summary Closes #4413 #8062 fig.tight_layout() could cause axes to flip sign if the title was too big, and cause the whole thing to Error if the title was really big. This PR adds a check that t...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/10915
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0f5d0d2e-bf7c-3ebd-9534-38c051933c8f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C410:2961BA:15D554:1E003F:6A551CEE |
| html-safe-nonce | 893f11e41db60333e03c2845e987e98eeeacf962813c01e46ab82813e4783768 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDEwOjI5NjFCQToxNUQ1NTQ6MUUwMDNGOjZBNTUxQ0VFIiwidmlzaXRvcl9pZCI6IjE3NDc4Mzk3OTQ3NDk0NDc0MDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c3ebf5ab90431f5d3b21475c4d2cf900ba25b286cea7d81146c7992ff78ff0bf |
| hovercard-subject-tag | pull_request:178222285 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/matplotlib/matplotlib/pull/10915/files |
| twitter:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1562854?s=400&v=4 |
| og:image:alt | PR Summary Closes #4413 #8062 fig.tight_layout() could cause axes to flip sign if the title was too big, and cause the whole thing to Error if the title was really big. This PR adds a check that t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 682d273eacb2ac51680c6eb9c0b270f029f7ce74c32090f319083c34497e28a5 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b6d37c6470adadff4194742daaab9a817cc4980 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width