René's URL Explorer Experiment


Title: Adding colorbar without affecting the plotting area size. · Issue #15010 · matplotlib/matplotlib · GitHub

Open Graph Title: Adding colorbar without affecting the plotting area size. · Issue #15010 · matplotlib/matplotlib

X Title: Adding colorbar without affecting the plotting area size. · Issue #15010 · matplotlib/matplotlib

Description: I would like to have a .mplstyle that by default produces square plots, per discussion started in #15001 and I still think "square" plots would be a reasonable thing to be able to set as default. tl;dr Want square plots of the same size ...

Open Graph Description: I would like to have a .mplstyle that by default produces square plots, per discussion started in #15001 and I still think "square" plots would be a reasonable thing to be able to set as default. t...

X Description: I would like to have a .mplstyle that by default produces square plots, per discussion started in #15001 and I still think "square" plots would be a reasonable thing to be able to set as ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding colorbar without affecting the plotting area size.","articleBody":"I would like to have a `.mplstyle` that by default produces square plots, per discussion started in #15001 and I still think \"square\" plots would be a reasonable thing to be able to set as default. \r\n\r\n**tl;dr Want square plots of the same size with or without colorbar. What should change is the xdim of the figure.**\r\n\r\nAnyway, for a single plot this is easy setting `figsize` either live or in the style. This doesn't let me specify the box size other than manually, but I can live with that\r\n```\r\nx = np.linspace(0,1,51)\r\ny = np.random.uniform(0,5,51)\r\nz = np.random.normal(0,1,51)\r\n\r\nfig = plt.figure(figsize=(5,5))\r\nax = fig.add_subplot()\r\nax.scatter(x, y, c = z);\r\n```\r\n![image](https://user-images.githubusercontent.com/13226500/62694605-f79d5780-b9d4-11e9-8774-e044fa671a54.png)\r\n\r\nIt gets trickier if I want to add a colorbar as well, but I would like the main box size to not change. The simplest method as far as I can tell is with `fig.colorbar()`\r\n```\r\nfig = plt.figure(figsize=(5,5))\r\nax = fig.add_subplot()\r\nsc = ax.scatter(x, y, c = z);\r\nfig.colorbar(sc, ax=ax);\r\n```\r\nHowever, this modifies the main box to fit within figure and changes the aspect.\r\n![image](https://user-images.githubusercontent.com/13226500/62694871-75f9f980-b9d5-11e9-8dcc-b3bb15586560.png)\r\n\r\nThe other option is to use `make_axes_locatable` Which if I understand correctly better splits the current axes and some reason this results in a less screwed up aspect than the above, but still changes it.\r\n```\r\nfrom mpl_toolkits.axes_grid1 import make_axes_locatable\r\nfig = plt.figure(figsize=(5,5))\r\nax = fig.add_subplot()\r\ndivider = make_axes_locatable(ax)\r\ncax = divider.append_axes('right', size=\"7%\", pad=0.2,)\r\nsc = ax.scatter(x, y, c = z);\r\ncbar = fig.colorbar(sc, cax=cax);\r\n```\r\n![image](https://user-images.githubusercontent.com/13226500/62695522-ccb40300-b9d6-11e9-9ad5-b1f264664792.png)\r\n\r\nCurrent best solution I found is resizing figure afterwards based on a set axes size with  @ImportanceOfBeingErnest 's answer https://stackoverflow.com/a/44971177. However, this is sub optimal because based on ticks/labels etc it doesn't always produce the same size output figure, which can be a problem when formatting a tex document later for example. \r\n\r\nOne solutions would be to have custom function(s) presetting the sizes manually like `make_rgb_axes` in https://matplotlib.org/3.1.1/gallery/axes_grid1/demo_axes_rgb.html which would get rid of the trial and error of setting the fig/ax size until it's just right. The obvious drawback of that is someone then wants a different size cbar or different padding it will screw up the layout and the fact that it needs to be packages somewhere else, which makes it more complicated for user to look up syntax/problems.\r\n","author":{"url":"https://github.com/andrzejnovak","@type":"Person","name":"andrzejnovak"},"datePublished":"2019-08-08T10:45:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":21},"url":"https://github.com/15010/matplotlib/issues/15010"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:13b92e7f-cbda-c760-2b99-ee774436d2fb
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD0A4:32BAC1:9E8F2C:D465D9:6A52B5E3
html-safe-nonce92557e8793386b0a26f8ebd922380662bbf84bb72715c2f4a2093be449806186
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEE0OjMyQkFDMTo5RThGMkM6RDQ2NUQ5OjZBNTJCNUUzIiwidmlzaXRvcl9pZCI6IjM0MDgzNzAzNTQzNTUzNTMwNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2232ec2f9e6dae9541af40841d19407c5f1b3520e4280670db47547e23b6a5ae
hovercard-subject-tagissue:478392111
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/15010/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bcec47eb1df4d8ec5513239ad160fee31225c97b574538a9f1e35c647aa2fd5f/matplotlib/matplotlib/issues/15010
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bcec47eb1df4d8ec5513239ad160fee31225c97b574538a9f1e35c647aa2fd5f/matplotlib/matplotlib/issues/15010
og:image:altI would like to have a .mplstyle that by default produces square plots, per discussion started in #15001 and I still think "square" plots would be a reasonable thing to be able to set as default. t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameandrzejnovak
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/15010#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F15010
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%2F15010
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/15010
Reloadhttps://github.com/matplotlib/matplotlib/issues/15010
Reloadhttps://github.com/matplotlib/matplotlib/issues/15010
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/15010
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/15010
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 408 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
Adding colorbar without affecting the plotting area size.https://github.com/matplotlib/matplotlib/issues/15010#top
https://github.com/andrzejnovak
andrzejnovakhttps://github.com/andrzejnovak
on Aug 8, 2019https://github.com/matplotlib/matplotlib/issues/15010#issue-478392111
#15001https://github.com/matplotlib/matplotlib/pull/15001
https://user-images.githubusercontent.com/13226500/62694605-f79d5780-b9d4-11e9-8774-e044fa671a54.png
https://user-images.githubusercontent.com/13226500/62694871-75f9f980-b9d5-11e9-8dcc-b3bb15586560.png
https://user-images.githubusercontent.com/13226500/62695522-ccb40300-b9d6-11e9-9ad5-b1f264664792.png
@ImportanceOfBeingErnesthttps://github.com/ImportanceOfBeingErnest
https://stackoverflow.com/a/44971177https://stackoverflow.com/a/44971177
https://matplotlib.org/3.1.1/gallery/axes_grid1/demo_axes_rgb.htmlhttps://matplotlib.org/3.1.1/gallery/axes_grid1/demo_axes_rgb.html
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.