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/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:9c5e1c97-1213-70cd-beaa-911e3b4d0979
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA45E:39DB0D:A66FB9:E92BD1:697B93E1
html-safe-nonce10e8969d472a4251b0cc4db01b6582656b4523c10c0c9c558e55497450df4597
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDVFOjM5REIwRDpBNjZGQjk6RTkyQkQxOjY5N0I5M0UxIiwidmlzaXRvcl9pZCI6IjQxMDQ4OTMxOTM2Njc3MTE5NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf6b12a11918c7adcd8dd5b3f88993bb02a25c8b8b2dfcf7a110caa4b7d257cfd
hovercard-subject-tagpull_request:353384856
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/proplot-dev/proplot/pull/89/files
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
None50d60071257d18b32330d912202dc320d501c221ea1591db8fbf19715460d571
turbo-cache-controlno-preview
diff-viewunified
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
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasedcefb04b18d0f0164691e133411da1c4c92e910c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files#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%2Ffiles
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%2Ffiles
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%2Ffiles&source=header-repo&source_repo=proplot-dev%2Fproplot
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
Reloadhttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
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/files
Implement Axes.format features with individual setters https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files#top
Show all changes 1 commit https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
de931ef Initial commit lukelbd Dec 16, 2019 https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/commits/de931ef4c5c9022b8287a22db0491e0ee390a2fd
Clear filters https://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
Please reload this pagehttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
Please reload this pagehttps://patch-diff.githubusercontent.com/proplot-dev/proplot/pull/89/files
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.