Title: [Bug]: LayoutEngine rect not respected when saving figure with `rcParams['figure.constrained_layout.use'] = True` · Issue #24389 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: LayoutEngine rect not respected when saving figure with `rcParams['figure.constrained_layout.use'] = True` · Issue #24389 · matplotlib/matplotlib
X Title: [Bug]: LayoutEngine rect not respected when saving figure with `rcParams['figure.constrained_layout.use'] = True` · Issue #24389 · matplotlib/matplotlib
Description: Bug summary I use the rect parameter of the figure's layout engine to set figure margins. For figures with layout='constrained' this parameter appears to be ignored if rcParams['figure.constrained_layout.use'] is True when saving the fig...
Open Graph Description: Bug summary I use the rect parameter of the figure's layout engine to set figure margins. For figures with layout='constrained' this parameter appears to be ignored if rcParams['figure.constrained_...
X Description: Bug summary I use the rect parameter of the figure's layout engine to set figure margins. For figures with layout='constrained' this parameter appears to be ignored if rcParams['fig...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24389
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: LayoutEngine rect not respected when saving figure with `rcParams['figure.constrained_layout.use'] = True`","articleBody":"### Bug summary\r\n\r\nI use the `rect` parameter of the figure's layout engine to set figure margins. For figures with `layout='constrained'` this parameter appears to be ignored if `rcParams['figure.constrained_layout.use']` is `True` when saving the figure. \r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nplt.rcParams['figure.constrained_layout.use']=True\r\nfig, ax = plt.subplots()\r\nengine = fig.get_layout_engine()\r\nengine.set(rect=[0.1,0.1,0.8,0.8]) # (left, bottom, width, height)\r\nengine.execute(fig)\r\nfig.savefig('test-constrained-True.png')\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nThe saved figure does not have the expected layout. It does not match the figure displayed interactively. The axes extend to the edges of the figure area.\r\n\r\n\r\n\r\n### Expected outcome\r\n\r\nThe saved figure has matches what is shown interactively. The axes do not extend to the edges of the figure area, respecting the `rect` parameter. This saved figure is generated with the code, which does not demonstrate the bug:\r\n```python\r\nplt.rcParams['figure.constrained_layout.use'] = False\r\nfig, ax = plt.subplots(layout='constrained')\r\nengine = fig.get_layout_engine()\r\nengine.set(rect=[0.1,0.1,0.8,0.8]) # (left, bottom, width, height)\r\nengine.execute(fig)\r\nfig.savefig('test-constrained-False.png')\r\n```\r\n\r\n\r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\nWindows\r\n\r\n### Matplotlib Version\r\n\r\n3.6.1\r\n\r\n### Matplotlib Backend\r\n\r\nQt5Agg\r\n\r\n### Python version\r\n\r\n3.10.6\r\n\r\n### Jupyter version\r\n\r\nn/a\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/s-bear","@type":"Person","name":"s-bear"},"datePublished":"2022-11-07T04:30:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/24389/matplotlib/issues/24389"}
| 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:0a4bdbb7-606e-402e-be91-0c83c56488d5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECB0:1B3289:F83D9C:151E7A8:6A520433 |
| html-safe-nonce | 86ba4fc436eafa88ba736a45c18b2c6c6c6fefc03073e30dce6912cb38c9390e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0IwOjFCMzI4OTpGODNEOUM6MTUxRTdBODo2QTUyMDQzMyIsInZpc2l0b3JfaWQiOiI0MTQ5NDQ5NzU5OTM2MDg3MDkxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d3042a0d3dc7bb04c71f56f80bf27ed857e370a1c260235b768d9b0ec2d49d12 |
| hovercard-subject-tag | issue:1437750394 |
| 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/24389/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c41edaf1cc1adee5dac9b3be8fefa800523273201b899eb07615cd1a0a31b27a/matplotlib/matplotlib/issues/24389 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c41edaf1cc1adee5dac9b3be8fefa800523273201b899eb07615cd1a0a31b27a/matplotlib/matplotlib/issues/24389 |
| og:image:alt | Bug summary I use the rect parameter of the figure's layout engine to set figure margins. For figures with layout='constrained' this parameter appears to be ignored if rcParams['figure.constrained_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | s-bear |
| 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