Title: [Bug]: constrained_layout_pads as kwargs of Figure · Issue #22029 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: constrained_layout_pads as kwargs of Figure · Issue #22029 · matplotlib/matplotlib
X Title: [Bug]: constrained_layout_pads as kwargs of Figure · Issue #22029 · matplotlib/matplotlib
Description: Bug summary According to the figure documentation (other parameters) it should be possible pass figure kwargs in plt.subplots(): fig, ax = plt.subplots(layout='constrained', constrained_layout_pads={'w_pad': 0.5, 'h_pad': 0.5}) which res...
Open Graph Description: Bug summary According to the figure documentation (other parameters) it should be possible pass figure kwargs in plt.subplots(): fig, ax = plt.subplots(layout='constrained', constrained_layout_pads...
X Description: Bug summary According to the figure documentation (other parameters) it should be possible pass figure kwargs in plt.subplots(): fig, ax = plt.subplots(layout='constrained', constrained_lay...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22029
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: constrained_layout_pads as kwargs of Figure","articleBody":"### Bug summary\n\nAccording to the [figure documentation (other parameters)](https://matplotlib.org/stable/api/figure_api.html#module-matplotlib.figure) it should be possible pass `figure` kwargs in `plt.subplots()`:\r\n```\r\nfig, ax = plt.subplots(layout='constrained',\r\n constrained_layout_pads={'w_pad': 0.5, 'h_pad': 0.5})\r\n```\r\n\r\nwhich results, however, in a\r\n\r\n`TypeError: set_constrained_layout_pads() takes 1 positional argument but 2 were given`\r\n\r\nThe documentation mentions a single value (`float`), although the parameter name is in plural (and [set_constrained_layout_pads](https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.set_constrained_layout_pads) takes up to four parameters):\r\n\r\n\u003e **constrained_layout_pads** float, default: rcParams[\"figure.constrained_layout.w_pad\"] (default: 0.04167)\r\n\r\nbut `plt.subplots(constrained_layout_pads=0.5)` results in the same error.\r\n\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots(layout='constrained',\r\n constrained_layout_pads={'w_pad': 0.5, 'h_pad': 0.5})\n```\n\n\n### Actual outcome\n\n```\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/pyplot.py\", line 1434, in subplots\r\n fig = figure(**fig_kw)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/pyplot.py\", line 787, in figure\r\n manager = new_figure_manager(\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/pyplot.py\", line 306, in new_figure_manager\r\n return _backend_mod.new_figure_manager(*args, **kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/backend_bases.py\", line 3493, in new_figure_manager\r\n fig = fig_cls(*args, **kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/figure.py\", line 2238, in __init__\r\n super().__init__(**kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/figure.py\", line 216, in __init__\r\n self.set(**kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/artist.py\", line 116, in \u003clambda\u003e\r\n cls.set = lambda self, **kwargs: Artist.set(self, **kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/artist.py\", line 1164, in set\r\n return self.update(kwargs)\r\n\r\n File \"/usr/lib/python3.10/site-packages/matplotlib/artist.py\", line 1066, in update\r\n ret.append(func(v))\r\n\r\nTypeError: Figure.set_constrained_layout_pads() takes 1 positional argument but 2 were given\r\n```\n\n### Expected outcome\n\nno error\n\n### Additional information\n\n\r\nalso discussed at [discours](https://discourse.matplotlib.org/t/setting-constrained-layout-pads-in-plt-subplots/22482)\n\n### Operating system\n\nArch\n\n### Matplotlib Version\n\n3.5.1\n\n### Matplotlib Backend\n\nQt5Agg\n\n### Python version\n\n3.10.1\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nLinux package manager","author":{"url":"https://github.com/StefRe","@type":"Person","name":"StefRe"},"datePublished":"2021-12-21T20:06:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/22029/matplotlib/issues/22029"}
| 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:82c91162-256d-d33d-f7ba-e06cacbcba61 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85F0:23BC1B:14279A5:1C758A6:6A50B121 |
| html-safe-nonce | 9694465d6d8ff24abcc6cf872cbed02cc5ab2cae475652879c8fa6310d934c55 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUYwOjIzQkMxQjoxNDI3OUE1OjFDNzU4QTY6NkE1MEIxMjEiLCJ2aXNpdG9yX2lkIjoiNDUzMDI3ODE3NDk5NTU1ODY4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0e334c1b35e30d720d8fc3003bc1f2722d2724d42916c733f2a25274e2e5ee63 |
| hovercard-subject-tag | issue:1086192568 |
| 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/22029/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6c77f9f6d58aa0565b71a9b123ec2545b4fc4abc93e6def8b4154c03a89b36d7/matplotlib/matplotlib/issues/22029 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6c77f9f6d58aa0565b71a9b123ec2545b4fc4abc93e6def8b4154c03a89b36d7/matplotlib/matplotlib/issues/22029 |
| og:image:alt | Bug summary According to the figure documentation (other parameters) it should be possible pass figure kwargs in plt.subplots(): fig, ax = plt.subplots(layout='constrained', constrained_layout_pads... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | StefRe |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width