Title: Should constrained_layout work as plt.figure() argument? · Issue #15821 · matplotlib/matplotlib · GitHub
Open Graph Title: Should constrained_layout work as plt.figure() argument? · Issue #15821 · matplotlib/matplotlib
X Title: Should constrained_layout work as plt.figure() argument? · Issue #15821 · matplotlib/matplotlib
Description: Bug report Bug summary Might be a documentation issue. The constrainedlayout_guide says constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are using the respective argument to subplots() ...
Open Graph Description: Bug report Bug summary Might be a documentation issue. The constrainedlayout_guide says constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are usin...
X Description: Bug report Bug summary Might be a documentation issue. The constrainedlayout_guide says constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are usin...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/15821
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Should constrained_layout work as plt.figure() argument?","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nMight be a documentation issue. The [constrainedlayout_guide](https://matplotlib.org/tutorials/intermediate/constrainedlayout_guide.html) says\r\n\r\n\u003e constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are\r\n\u003e * using the respective argument to `subplots()` or `figure()`,\r\n\u003e * [...]\r\n\r\nHowever, `fig = plt.figure(constrained_layout=True)` does not seem to have any effect.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\n\r\ndef example_plot(ax, fontsize=12):\r\n ax.plot([1, 2])\r\n ax.set_xlabel('x-label', fontsize=fontsize)\r\n ax.set_ylabel('y-label', fontsize=fontsize)\r\n ax.set_title('Title', fontsize=fontsize)\r\n\r\nfig = plt.figure(constrained_layout=True)\r\nax1 = fig.add_subplot(211)\r\nax2 = fig.add_subplot(212)\r\n\r\nfor ax in [ax1, ax2]:\r\n example_plot(ax, fontsize=24)\r\nplt.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\n\u003c!--A description of the expected outcome from the code snippet--\u003e\r\n\u003c!--If this used to work in an earlier version of Matplotlib, please note the version it used to work on--\u003e\r\n\r\n\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Windows 8.1\r\n * Matplotlib version: 3.1.0\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): Qt5Agg\r\n * Python version: 3.7\r\n\r\n","author":{"url":"https://github.com/ImportanceOfBeingErnest","@type":"Person","name":"ImportanceOfBeingErnest"},"datePublished":"2019-12-03T15:56:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/15821/matplotlib/issues/15821"}
| 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:3d96d874-5d2c-fb56-4092-cd600f11a633 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3B4:27A3BF:11E6DB7:1883E3E:6A53C426 |
| html-safe-nonce | b7116d75b110a269cf6c33b885b5df7950e0a2fd0f9b780df347648e0bccf8a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0I0OjI3QTNCRjoxMUU2REI3OjE4ODNFM0U6NkE1M0M0MjYiLCJ2aXNpdG9yX2lkIjoiODYyODc1NjgyNDY0NzI1NTA3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 414a50cc2fe5407bd519a7e4b4c1837754599becf5dd623eec49acd39f5ddd74 |
| hovercard-subject-tag | issue:532085602 |
| 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/15821/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7e1aaab3c9b509a635db61001e631504ea7ece9f8dd536053cf05f10737228d6/matplotlib/matplotlib/issues/15821 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7e1aaab3c9b509a635db61001e631504ea7ece9f8dd536053cf05f10737228d6/matplotlib/matplotlib/issues/15821 |
| og:image:alt | Bug report Bug summary Might be a documentation issue. The constrainedlayout_guide says constrained_layout needs to be activated before any axes are added to a figure. Two ways of doing so are usin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ImportanceOfBeingErnest |
| 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