Title: BUG: Refresh 3D axis projection before tightbbox to fix constrained layout overlap (GH#31277) by tinezivic · Pull Request #31548 · matplotlib/matplotlib · GitHub
Open Graph Title: BUG: Refresh 3D axis projection before tightbbox to fix constrained layout overlap (GH#31277) by tinezivic · Pull Request #31548 · matplotlib/matplotlib
X Title: BUG: Refresh 3D axis projection before tightbbox to fix constrained layout overlap (GH#31277) by tinezivic · Pull Request #31548 · matplotlib/matplotlib
Description: Closes #31277 constrained_layout calls Axis3D.get_tightbbox() before any draw(), so tick-label 2D positions are not initialized yet and the returned bbox is too small. That leads to overlap between the 3D axis tick labels and the title of the subplot below. The fix adds a one-time no-output draw() inside get_tightbbox(), guarded by _tightbbox_initialized, and only when constrained_layout is active. If needed, axes.M/axes.invM are initialized first. This keeps behavior unchanged for non-constrained layouts. Before / After: Before (bug) After (fix) Minimal reproducer: fig = plt.figure(constrained_layout=True) ax1 = fig.add_subplot(2, 1, 1, projection="3d") ax1.set_title("3D Plot") ax2 = fig.add_subplot(2, 1, 2) ax2.set_title("2D Plot") plt.show() test_stem3d baseline is updated because it uses constrained_layout=True, so this fix changes the rendered output (tick labels are no longer clipped). I used GitHub Copilot to help explore the code path; all changes were reviewed and tested manually.
Open Graph Description: Closes #31277 constrained_layout calls Axis3D.get_tightbbox() before any draw(), so tick-label 2D positions are not initialized yet and the returned bbox is too small. That leads to overlap between...
X Description: Closes #31277 constrained_layout calls Axis3D.get_tightbbox() before any draw(), so tick-label 2D positions are not initialized yet and the returned bbox is too small. That leads to overlap between...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/31548
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a453f278-7342-b498-625c-181601a10b2e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 80D8:22B385:10D21D0:1699E35:6A5AA638 |
| html-safe-nonce | a92c705e88159cf71434e66ceb5d47d87e2879c17716053f44730b461a2f8169 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEQ4OjIyQjM4NToxMEQyMUQwOjE2OTlFMzU6NkE1QUE2MzgiLCJ2aXNpdG9yX2lkIjoiMjMxMDk3OTEwMDM5NDMwMDk4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 93fd84aea21ffbed327d57d502fbd042485886312206f90ff2653b872f6faa25 |
| hovercard-subject-tag | pull_request:3569513079 |
| 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/31548/files |
| twitter:image | https://avatars.githubusercontent.com/u/43860297?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/43860297?s=400&v=4 |
| og:image:alt | Closes #31277 constrained_layout calls Axis3D.get_tightbbox() before any draw(), so tick-label 2D positions are not initialized yet and the returned bbox is too small. That leads to overlap between... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 17a57ee6ab03686731c491fccb57e6a97c066a29d7cdf1a7d83c46f5c56684fc |
| 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 | 5cb870aa6b86b87be75e23ca7caec54726a25af9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width