René's URL Explorer Experiment


Title: Implement Axes.format features with individual setters by lukelbd · Pull Request #89 · proplot-dev/proplot · GitHub

Open Graph Title: Implement Axes.format features with individual setters by lukelbd · Pull Request #89 · proplot-dev/proplot

X Title: Implement Axes.format features with individual setters by lukelbd · Pull Request #89 · proplot-dev/proplot

Description: Starting this PR to keep #63 on everyone's radar. Along with #50 and #45 this is one of the major (but mostly internal) changes I am considering for the version 1.0 release. ProPlot adds "batch" setter methods called format to every Axes subclass. The idea is it's quicker to call 1 method with 10 keyword arguments rather than 10 methods on 10 lines. Interestingly, it looks like the Plots.jl julia package follows a similar philosophy (see the "Lorenz attractor" example). However: It seems kind of sloppy / unpythonic to me to have individual settings that can only be modified with a batch setter. It also makes the setter methods really long and difficult to maintain. (no longer valid; see below) I want to encourage batch setting but permit individual one-liner setting if the user so chooses. One of my goals for version 1 is to incorporate ProPlot internals more closely with matplotlib, and matplotlib apparently has its own batch setter, Artist.set. However nobody uses it, probably because (1) it seldom appears in the online examples and (2) the valid arguments are not explicitly documented, which is confusing for new userss. With this PR, I'd like to combine the features of Axes.format with Artist.update and Artist.set by overriding the latter for axes artists. I will deprecate format and break up the format tasks into individual setters, but encourage using the batch setters by using them in all of the examples and documenting the acceptable keyword args. Here is some pseudocode to outline the general idea. # The batch setters @cbook.deprecated("1.0.0", alternative="Axes.set(...)") # use matplotlib's deprecation system? def format(self, **kwargs): _warn_proplot( 'Axes.format() was deprecated in version 1.0.0. Please use `Axes.set()` instead.' ) # or "deprecation" with a simple warning return self.set(*args, **kwargs) def set(self, **kwargs): # Just like Artist.set(), process aliases here, e.g. `xticklabels` for `xformatter` # May just add `_alias_map` and `_prop_order` attributes to Axes! self._alias_map = ... # make sure these hidden props are stable! self._prop_order = ... # then filter out rc props here, and maybe we can have some sort of # rcupdate() method that updates *any* rc property that has changed rcprops, kwargs = _process_kwargs(kwargs) self.applyrc(rcprops) super().set(**kwargs) def update(self, props): # *Superset* of internal matplotlib.artist.Artist.update() # Permit passing *keyword arguments* to each setter # Example: If we get `xlim` and `xlim_kw`, call `Axes.set_xlim(xlim, **xlim_kw)` def _update_property(self, k, v, **kwargs): k = k.lower() if k in {'axes'}: return setattr(self, k, v) else: func = getattr(self, 'set_' + k, None) if not callable(func): raise AttributeError( f'{type(self).__name__!r} object has no property {k!r}.') return func(v) with cbook._setattr_cm(self, eventson=False): ret = [] for key, value in _kwargs_not_ending_in_kw(kwargs).items(): kw = _kwarg_ending_in_kw(key) ret.append(_update_property(self, k, v, **kw)) return ret # Helper method that looks for rc setting names passed # to the bulk setters def applyrc(self, **kwargs): # perform various actions currently spread around Axes.format() with plot.rc.context(**kwargs): # apply "cached" props (i.e. props changed in this block) # plot.rc.fill(props, cached=True) # plot.rc.get(props, cached=True) # etc. pass # The individual setters # These replace features originally coded in Axes.format def set_abcstyle(self, style): if not isinstance(style, str) or (style.count('a') != 1 and style.count('A') != 1): raise ValueError abc = _abc(self.number - 1) if 'A' in style: abc = abc.upper() abc = re.sub('[aA]', abc, abcstyle) self.abc.set_text(abc) def set_xticks(self, locator, **kwargs): locator = axistools.Locator(locator, **kwargs) self.xaxis.set_major_locator(locator) def set_xminorticks(self, locator, **kwargs): locator = axistools.Locator(locator, **kwargs) self.xaxis.set_minor_locator(locator) def set_xticklabels(self, formatter, **kwargs): formatter = axistools.Formatter(formatter, **kwargs) self.xaxis.set_major_formatter(formatter) ... Then to encourage using the batch setters, we can concatenate docstrings from each individual setter: # Documentation builder def _get_setter_docs(self): # Maybe just retrieve first sentence of each docstring, # and look at `Axes._alias_map` for aliases! .... Axes.set.__doc__ = f""" Bulk update the axes. Parameters ----------- {_get_setter_docs(Axes)} """ # Results in the following docstring # (not sure how we can consistently get argument types though) """ Parameters ----------- xlim : (float, float), optional Call `~Axes.set_xlim`. Set the x-axis view limits. ylim : (float, float), optional Call `~Axes.set_ylim`. Set the y-axis view limits. ... etc ... """

Open Graph Description: Starting this PR to keep #63 on everyone's radar. Along with #50 and #45 this is one of the major (but mostly internal) changes I am considering for the version 1.0 release. ProPlot adds "...

X Description: Starting this PR to keep #63 on everyone's radar. Along with #50 and #45 this is one of the major (but mostly internal) changes I am considering for the version 1.0 release. ProPlot adds &a...

Opengraph URL: https://github.com/proplot-dev/proplot/pull/89

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:b9fc572b-1788-d096-8077-9285f480ffcb
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idCA78:15BA65:1FE7257:2B0BA3A:697AAFDD
html-safe-noncebdebc6ca4b9a70d7ce0fe71f54633bae8369fe2c8923451382aeec4ff4e2f91b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTc4OjE1QkE2NToxRkU3MjU3OjJCMEJBM0E6Njk3QUFGREQiLCJ2aXNpdG9yX2lkIjoiNjUyMzQwMTk2OTY3MzYxMzI3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8f7de4db127d4bf196d8489b333c7f39641ec2cee1e84ccb05a23fb57d47fd91
hovercard-subject-tagpull_request:353384856
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/proplot-dev/proplot/pull/89/checks
twitter:imagehttps://avatars.githubusercontent.com/u/19657652?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19657652?s=400&v=4
og:image:altStarting this PR to keep #63 on everyone's radar. Along with #50 and #45 this is one of the major (but mostly internal) changes I am considering for the version 1.0 release. ProPlot adds "...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None33acda8ebf71b04c9d33b494d2b6e0db48193ec89eb3ad92a9539d491fa9a3da
turbo-cache-controlno-preview
go-importgithub.com/proplot-dev/proplot git https://github.com/proplot-dev/proplot.git
octolytics-dimension-user_id108025793
octolytics-dimension-user_loginproplot-dev
octolytics-dimension-repository_id113293661
octolytics-dimension-repository_nwoproplot-dev/proplot
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id113293661
octolytics-dimension-repository_network_root_nwoproplot-dev/proplot
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4f714a84d3384e467839505ed65f968fc01aedf1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fproplot-dev%2Fproplot%2Fpull%2F89%2Fchecks
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://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fproplot-dev%2Fproplot%2Fpull%2F89%2Fchecks
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=proplot-dev%2Fproplot
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
proplot-dev https://patch-diff.githubusercontent.com/proplot-dev
proplothttps://patch-diff.githubusercontent.com/proplot-dev/proplot
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fproplot-dev%2Fproplot
Fork 97 https://patch-diff.githubusercontent.com/login?return_to=%2Fproplot-dev%2Fproplot
Star 1.1k https://patch-diff.githubusercontent.com/login?return_to=%2Fproplot-dev%2Fproplot
Code https://patch-diff.githubusercontent.com/proplot-dev/proplot
Issues 88 https://patch-diff.githubusercontent.com/proplot-dev/proplot/issues
Pull requests 7 https://patch-diff.githubusercontent.com/proplot-dev/proplot/pulls
Discussions https://patch-diff.githubusercontent.com/proplot-dev/proplot/discussions
Actions https://patch-diff.githubusercontent.com/proplot-dev/proplot/actions
Projects 0 https://patch-diff.githubusercontent.com/proplot-dev/proplot/projects
Security 0 https://patch-diff.githubusercontent.com/proplot-dev/proplot/security
Insights https://patch-diff.githubusercontent.com/proplot-dev/proplot/pulse
Code https://patch-diff.githubusercontent.com/proplot-dev/proplot
Issues https://patch-diff.githubusercontent.com/proplot-dev/proplot/issues
Pull requests https://patch-diff.githubusercontent.com/proplot-dev/proplot/pulls
Discussions https://patch-diff.githubusercontent.com/proplot-dev/proplot/discussions
Actions https://patch-diff.githubusercontent.com/proplot-dev/proplot/actions
Projects https://patch-diff.githubusercontent.com/proplot-dev/proplot/projects
Security https://patch-diff.githubusercontent.com/proplot-dev/proplot/security
Insights https://patch-diff.githubusercontent.com/proplot-dev/proplot/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fproplot-dev%2Fproplot%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fproplot-dev%2Fproplot%2Fissues%2Fnew%2Fchoose
lukelbdhttps://patch-diff.githubusercontent.com/lukelbd
masterhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/tree/master
format-with-settershttps://patch-diff.githubusercontent.com/proplot-dev/proplot/tree/format-with-setters
Conversation 2 https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89
Commits 1 https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/commits
Checks 0 https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
Files changed https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
Please reload this pagehttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
Please reload this pagehttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
Implement Axes.format features with individual setters https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks#top
Please reload this pagehttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/checks
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.