René's URL Explorer Experiment


Title: [Bug]: constrained layout clips y-label above y-axis · Issue #27877 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: constrained layout clips y-label above y-axis · Issue #27877 · matplotlib/matplotlib

X Title: [Bug]: constrained layout clips y-label above y-axis · Issue #27877 · matplotlib/matplotlib

Description: Bug summary When placing the y-label above the y-axis/spine, it gets clipped with constrained layout. It works OK with tight layout and on the left in constrained layout. Code for reproduction import matplotlib.pyplot as plt x = range(10...

Open Graph Description: Bug summary When placing the y-label above the y-axis/spine, it gets clipped with constrained layout. It works OK with tight layout and on the left in constrained layout. Code for reproduction impo...

X Description: Bug summary When placing the y-label above the y-axis/spine, it gets clipped with constrained layout. It works OK with tight layout and on the left in constrained layout. Code for reproduction impo...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/27877

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: constrained layout clips y-label above y-axis","articleBody":"### Bug summary\r\n\r\nWhen placing the y-label above the y-axis/spine, it gets clipped with constrained layout. It works OK with tight layout and on the left in constrained layout.\r\n\r\n### Code for reproduction\r\n\r\n```Python\r\nimport matplotlib.pyplot as plt\r\nx = range(10)\r\nlab = \"foo bar baz\"\r\n\r\n# with extra space it works, but the second plot with two lines gets\r\n# clipped.\r\nfig0, axes0 = plt.subplots(1, 2, constrained_layout=True)\r\n[ax.plot(x, x) for ax in axes0]\r\n[ax.set_ylabel(\"\\n\".join([lab]*(i+1)),\r\n               y=1.0,\r\n               rotation=\"horizontal\",\r\n               horizontalalignment=\"left\",\r\n               multialignment=\"left\",)\r\n for i, ax in enumerate(axes0)]\r\n\r\n# single plot with one line also gets clipped\r\nfig1, ax1 = plt.subplots(constrained_layout=True)\r\nax1.plot(x, x)\r\nax1.set_ylabel(lab,\r\n               y=1.0,\r\n               rotation=\"horizontal\",\r\n               horizontalalignment=\"left\",\r\n               multialignment=\"left\",)\r\n\r\n# For reference it works fine when placing the ylab on the 'side'\r\n# as a conventional matplotlib plot\r\nfig2, ax2 = plt.subplots(constrained_layout=True)\r\nax2.plot(x, x)\r\nax2.set_ylabel(f\"{lab}\\n{lab}\",\r\n               rotation=\"horizontal\",\r\n               horizontalalignment=\"right\",\r\n               multialignment=\"right\",)\r\n\r\nfor i, fig in enumerate((fig0, fig1, fig2)):\r\n    fig.savefig(f\"fig{i}.png\")\r\n```\r\n\r\n### Actual outcome\r\n\r\nThe y-label gets clipped. The second plot should have a two line long y label. \r\n![fig0](https://github.com/matplotlib/matplotlib/assets/666845/d3d58412-9646-40d8-90a7-048bc5903fd9)\r\n\r\nIt also happens with a y-label that is just one line:\r\n![fig1](https://github.com/matplotlib/matplotlib/assets/666845/056c95b3-7159-49c9-bc14-db80cd485e99)\r\n\r\n\r\n### Expected outcome\r\n\r\nI would expect the y label to be included, even when putting it above the axis. Example with tight layout (`fig1.tight_layout()`)\r\n\r\n![fig1_tight](https://github.com/matplotlib/matplotlib/assets/666845/e60bfa47-eb5f-4515-be7c-107769562de2)\r\n\r\n\r\n### Additional information\r\n\r\nI *think* this is a bug(?).  \r\nI have tried various vertical alignments, and it doesn't make much of a difference. I also tried to follow the legend `set_in_layout`-example in the [constrained layout guide](https://matplotlib.org/stable/users/explain/axes/constrainedlayout_guide.html#legends) without much luck.\r\n\r\nA temporary fix is to set the title to `' '` or increasing the constrained layout padding, I guess. \r\n\r\nNote that constrained layout works as expected with long y-labels on the left:\r\n\r\n![fig2](https://github.com/matplotlib/matplotlib/assets/666845/15f435ad-0150-41c3-8a55-6c2ec2346e3d)\r\n\r\n\r\n### Operating system\r\n\r\nWindows\r\n\r\n### Matplotlib Version\r\n\r\n3.8.0\r\n\r\n### Matplotlib Backend\r\n\r\nmodule://matplotlib_inline.backend_inline, but present in saved figures (`savefig`) \r\n\r\n### Python version\r\n\r\n3.12.1\r\n\r\n### Jupyter version\r\n\r\nJupyter console 6.6.3\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/pank","@type":"Person","name":"pank"},"datePublished":"2024-03-07T13:36:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/27877/matplotlib/issues/27877"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7c193503-77cc-1a48-ff8a-52ea58fda9dc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB09C:AE90C:3E7A97:5503E6:6A559920
html-safe-nonceece5f2c06de83a94c1ca1615d9787c7bfdb59aaa3e752287ae90b15cc6462208
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDlDOkFFOTBDOjNFN0E5Nzo1NTAzRTY6NkE1NTk5MjAiLCJ2aXNpdG9yX2lkIjoiODExOTY2NzQ3MDUxNDg4Njk0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1951b7ee1decb3d17d59ea79184b33c4a98c91ac7c8f6f1910f613a5af919c3e
hovercard-subject-tagissue:2173884921
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/27877/issue_layout
twitter:imagehttps://opengraph.githubassets.com/511d9616ddd9339081e9a744fd0187f86d7eb714daad4c4604731f049fa516bf/matplotlib/matplotlib/issues/27877
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/511d9616ddd9339081e9a744fd0187f86d7eb714daad4c4604731f049fa516bf/matplotlib/matplotlib/issues/27877
og:image:altBug summary When placing the y-label above the y-axis/spine, it gets clipped with constrained layout. It works OK with tight layout and on the left in constrained layout. Code for reproduction impo...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepank
hostnamegithub.com
expected-hostnamegithub.com
Noneb5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseaa21baa44893467b0b640d0300538f84ca8c475b
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/27877#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F27877
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F27877
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/27877
Reloadhttps://github.com/matplotlib/matplotlib/issues/27877
Reloadhttps://github.com/matplotlib/matplotlib/issues/27877
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/27877
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/27877
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 409 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
[Bug]: constrained layout clips y-label above y-axishttps://github.com/matplotlib/matplotlib/issues/27877#top
topic: geometry managerLayoutEngine, Constrained layout, Tight layouthttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20geometry%20manager%22
https://github.com/pank
pankhttps://github.com/pank
on Mar 7, 2024https://github.com/matplotlib/matplotlib/issues/27877#issue-2173884921
https://private-user-images.githubusercontent.com/666845/310896412-d3d58412-9646-40d8-90a7-048bc5903fd9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODM5OTQ5NTYsIm5iZiI6MTc4Mzk5NDY1NiwicGF0aCI6Ii82NjY4NDUvMzEwODk2NDEyLWQzZDU4NDEyLTk2NDYtNDBkOC05MGE3LTA0OGJjNTkwM2ZkOS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcxNFQwMjA0MTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jNzdkNzcwNTgzMGVkMTIwZWY3ZGFlNDk0ZWQyZjc1YjVmZGY1ODE5OTc1NTQyYTE3YWJlMGE0NjFhOWEwNzZjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.hEGD9YaBzQUIzYuS-We7GPiRDIABqlZTcPk7t9PGR84
https://private-user-images.githubusercontent.com/666845/310896408-056c95b3-7159-49c9-bc14-db80cd485e99.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb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C0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcxNFQwMjA0MTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMTg3MWMxY2VhMzYzNmQ2YWUxZWM1YTcwN2EyYzIzMDcyNGYyNmEzZTMxOWIyNzlkZjFkYzM0ZGZlODAyMzBlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.65XzdlC8MCkva0tKnvY4LveVPRU0SGhCJY1yLRYTf4I
constrained layout guidehttps://matplotlib.org/stable/users/explain/axes/constrainedlayout_guide.html#legends
https://private-user-images.githubusercontent.com/666845/310897257-15f435ad-0150-41c3-8a55-6c2ec2346e3d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODM5OTQ5NTYsIm5iZiI6MTc4Mzk5NDY1NiwicGF0aCI6Ii82NjY4NDUvMzEwODk3MjU3LTE1ZjQzNWFkLTAxNTAtNDFjMy04YTU1LTZjMmVjMjM0NmUzZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcxNFQwMjA0MTZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jZThjNDQ2YzlmZDk3MmM2NzAxZWFlMzFiYWQxMzBkNDExZjcxODY5NmYwZGY4YmE4YzgxODg4NDcyZjhiZmNmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.xTYDd4X2wN0urAUbhEG29myuyACSrEVQgPCiwLit458
topic: geometry managerLayoutEngine, Constrained layout, Tight layouthttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20geometry%20manager%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.