Title: [ENH]: support rect with constrained_layout ("layout only to part of the figure") · Issue #22623 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: support rect with constrained_layout ("layout only to part of the figure") · Issue #22623 · matplotlib/matplotlib
X Title: [ENH]: support rect with constrained_layout ("layout only to part of the figure") · Issue #22623 · matplotlib/matplotlib
Description: Problem tight_layout supports a rect option ("layout axes so that they fit within this rect instead of filling the entire figure"). It could be nice if constrained_layout also supported that. As an example use case, requested by @jklymak...
Open Graph Description: Problem tight_layout supports a rect option ("layout axes so that they fit within this rect instead of filling the entire figure"). It could be nice if constrained_layout also supported that. As an...
X Description: Problem tight_layout supports a rect option ("layout axes so that they fit within this rect instead of filling the entire figure"). It could be nice if constrained_layout also supported t...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22623
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: support rect with constrained_layout (\"layout only to part of the figure\")","articleBody":"### Problem\n\ntight_layout supports a rect option (\"layout axes so that they fit within this rect instead of filling the entire figure\"). It could be nice if constrained_layout also supported that.\r\n\r\nAs an example use case, requested by @jklymak on gitter:\r\n```python\r\nfrom pylab import *\r\n\r\nfig = figure(layout=\"constrained\")\r\naxs = fig.subplots(1, 3)\r\nfor ax in axs:\r\n for i in range(3):\r\n ax.plot(rand(3), rand(3), label=f\"dataset {i}\")\r\naxs[1].legend(ncol=3, loc=\"lower center\", bbox_to_anchor=(0.5, 1.0))\r\n\r\nfig = figure(layout=\"constrained\")\r\naxs = fig.subplots(1, 3)\r\nfor ax in axs:\r\n for i in range(3):\r\n ax.plot(rand(3), rand(3), label=f\"dataset {i}\")\r\nfig.legend(handles=axs[0].lines, ncol=3, loc=\"upper center\")\r\n\r\nshow()\r\n```\r\nThis draws e.g. three different coordinates of three datasets, and tries to have a single one-line legend at the center top.\r\n\r\nThe first try gives\r\n\r\ni.e. it would work if set_in_layout could be used to take the legend's y extent, but not its x extent (now that I think of it, that may be the better solution).\r\nThe second try gives\r\n\r\nwhich is where I think a rect option would work to avoid the axes overlapping the legend (you'd have to tweak the value a bit manually, though, to specify the upper bound of the rect). (Perhaps not the nicest solution, but \"could work when you just want to get a plot done\".)\r\n\r\n\n\n### Proposed solution\n\n_No response_","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2022-03-08T12:44:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/22623/matplotlib/issues/22623"}
| 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:719c3d3e-c48e-d437-0a2a-595e8385f52b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8168:278EE8:5B0491:7A3867:6A529BC6 |
| html-safe-nonce | 9902d736ca0d7635b3c59896d0402452ba6f84f685ae317b456af7a281f268c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTY4OjI3OEVFODo1QjA0OTE6N0EzODY3OjZBNTI5QkM2IiwidmlzaXRvcl9pZCI6IjM3MTI5ODk0MTUxNzU1MjczNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 84aafe7dda7eea0d20399783d262c5707f8bdae7589e96e32c5bacba46cdc3ae |
| hovercard-subject-tag | issue:1162613218 |
| 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/22623/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a4046a6047b5868c95f8b992dc532e3c19ae0d03677264f5c408ce46bcf09541/matplotlib/matplotlib/issues/22623 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a4046a6047b5868c95f8b992dc532e3c19ae0d03677264f5c408ce46bcf09541/matplotlib/matplotlib/issues/22623 |
| og:image:alt | Problem tight_layout supports a rect option ("layout axes so that they fit within this rect instead of filling the entire figure"). It could be nice if constrained_layout also supported that. As an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| 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