René's URL Explorer Experiment


Title: Idea: Reducing verbosity through more compact API patterns · Issue #30941 · matplotlib/matplotlib · GitHub

Open Graph Title: Idea: Reducing verbosity through more compact API patterns · Issue #30941 · matplotlib/matplotlib

X Title: Idea: Reducing verbosity through more compact API patterns · Issue #30941 · matplotlib/matplotlib

Description: Summary Matplotlib is often considered verbose. I've been pondering whether/how one could write the code more compact without completely reinventing our API. The two main points for simplification I've come up with are: Don't use set_* f...

Open Graph Description: Summary Matplotlib is often considered verbose. I've been pondering whether/how one could write the code more compact without completely reinventing our API. The two main points for simplification ...

X Description: Summary Matplotlib is often considered verbose. I've been pondering whether/how one could write the code more compact without completely reinventing our API. The two main points for simplificat...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Idea: Reducing verbosity through more compact API patterns","articleBody":"### Summary\n\nMatplotlib is often considered verbose. I've been pondering whether/how one could write the code more compact without completely reinventing our API. The two main points for simplification I've come up with are:\n\n- Don't use `set_*` for configuration, but instead do the configuration via kwargs. The `set_*` methods can be a fallback for mor complex configuration.\n- Don't hold a figure reference as it's rarely needed.\n\nWhat I explicitly do not want to change:\n- No breakage of existing API\n- No completely new interface namespace\n- No method chaining\n\nThis is just an early and wild idea, not a proposal. Thoughts and feedback are welcome.\n\n\n\n\n\n### Proposed fix\n\nThe ideas are illustrated on a slightly modified variant of https://matplotlib.org/devdocs/gallery/lines_bars_and_markers/simple_plot.html\n\nThe formal Axes interface approach is:\n\n```python\nfig, ax = plt.subplots()\nax.plot(t, s)\nax.set_xlabel('time (s)')\nax.set_ylabel('voltage (mV)')\nax.set_title('A simple plot')\nplt.show()\n```\n\nIn some parts, we already have replaced the individual setters by `ax.set(...)` with kwargs.\n```python\nfig, ax = plt.subplots()\nax.plot(t, s)\nax.set(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot')\nplt.show()\n```\n\n*Possible improvement 1:* Replace `ax.set(...)` by kwargs during Axes creation:\n```python\nfig, ax = plt.subplots(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot')\nax.plot(t, s)\nplt.show()\n```\n\n*Possible improvement 2:* Don't store a reference to the figure - rationale: The `fig, ax = plt.subplots()` pattern is quite boilerplate and you rarely need the figure. One can always get the figure via `ax.get_figure()` if needed, which is only mildy more work than holding a `fig` variable.\n\n```python\nax = plt.figure().subplots(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot')\nax.plot(t, s)\nplt.show()\n```\nWhat is still not so nice is that you still need the `plt.figure().subplots(` chaining for the simple single-Axes case. While \n```python\nax = plt.axes(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot')\n```\nworks with the same result, there's a caveat in that `plt.axes()` reuses an existing Figure if possible whereas `plt.figure().subplot()` always creates a new figure. That's a potential footgun and we may want to think whether there's a way around this. Otherwise\n```python\nax = plt.axes(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot')\nax.plot(t, s)\nplt.show()\n```\nwould look quite clean to me:\n- create an Axes with some properties set\n- add data\n- show\n\nIn jupyter notebooks you'd even not need the show and could (as an abbreviation, not as a universally recommended pattern) create the plot in one line:\n```python\nplt.axes(xlabel='time (s)', ylabel='voltage (mV)', title='A simple plot').plot(t, s)\n```\n\n\n\n\n","author":{"url":"https://github.com/timhoffm","@type":"Person","name":"timhoffm"},"datePublished":"2026-01-07T14:24:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/30941/matplotlib/issues/30941"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c08d6acd-0eee-93a0-faa1-9805b411e6b0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC696:8ADEB:64ABA8:88B633:6969DD9C
html-safe-nonce14a065cb822ce61ab2fde88ace349a10d15088c1ba47308c99060c649d2a03df
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjk2OjhBREVCOjY0QUJBODo4OEI2MzM6Njk2OUREOUMiLCJ2aXNpdG9yX2lkIjoiNTU5OTU5NTM0MDg1MTk2MTI0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac4a6f467403b10c621cfb9b1187558afcf5516d23167680a6640c0b05bf223763
hovercard-subject-tagissue:3788983412
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/30941/issue_layout
twitter:imagehttps://opengraph.githubassets.com/71c727aaed313364a086f9b9fc5c1e8961c1d8fb31589041ff0d251899c2ef66/matplotlib/matplotlib/issues/30941
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/71c727aaed313364a086f9b9fc5c1e8961c1d8fb31589041ff0d251899c2ef66/matplotlib/matplotlib/issues/30941
og:image:altSummary Matplotlib is often considered verbose. I've been pondering whether/how one could write the code more compact without completely reinventing our API. The two main points for simplification ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametimhoffm
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
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
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/30941#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F30941
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
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
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
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/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%2F30941
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/30941
Reloadhttps://github.com/matplotlib/matplotlib/issues/30941
Reloadhttps://github.com/matplotlib/matplotlib/issues/30941
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30941
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.2k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 22.2k 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 401 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects 2 https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/matplotlib/matplotlib/security
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/30941
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 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/30941
New issuehttps://github.com/login?return_to=https://github.com/matplotlib/matplotlib/issues/30941
#30952https://github.com/matplotlib/matplotlib/pull/30952
Idea: Reducing verbosity through more compact API patternshttps://github.com/matplotlib/matplotlib/issues/30941#top
#30952https://github.com/matplotlib/matplotlib/pull/30952
Maintenancehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22Maintenance%22
v3.10-dochttps://github.com/matplotlib/matplotlib/milestone/99
https://github.com/timhoffm
https://github.com/timhoffm
timhoffmhttps://github.com/timhoffm
on Jan 7, 2026https://github.com/matplotlib/matplotlib/issues/30941#issue-3788983412
https://matplotlib.org/devdocs/gallery/lines_bars_and_markers/simple_plot.htmlhttps://matplotlib.org/devdocs/gallery/lines_bars_and_markers/simple_plot.html
Maintenancehttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22Maintenance%22
v3.10-docNo due datehttps://github.com/matplotlib/matplotlib/milestone/99
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.