Title: Add "properties" to all matplotlib artists by lukelbd · Pull Request #168 · proplot-dev/proplot · GitHub
Open Graph Title: Add "properties" to all matplotlib artists by lukelbd · Pull Request #168 · proplot-dev/proplot
X Title: Add "properties" to all matplotlib artists by lukelbd · Pull Request #168 · proplot-dev/proplot
Description: This PR is related to #89 and adds @property setters and getters to every single Artist subclass. The core logic for this turns out to be surprisingly simple: https://github.com/lukelbd/proplot/blob/5d29f3148975e898452c4101dab6338e2908c50f/proplot/artist.py#L14-L50 After this PR is merged proplot users will be able to use the much cleaner, more object-oriented "dot" syntax for changing matplotlib artist attributes: # Original API fig, ax = pyplot.subplots() ax.set_title('Title') ax.set_xlabel('xlabel') ax.set_xticks([1, 2, 3]) h, = ax.plot(...) h.set_color('red') h.set_linewidth(1) # ProPlot API if this is merged fig, ax = proplot.subplots() ax.format(title='Title', xlabel='xlabel', xticks=[1, 2, 3]) # with bulk setter ax.title = 'Title' # with individual setters ax.xlabel = 'xlabel' ax.xticks = [1, 2, 3] h, = ax.plot(...) h.color = 'red' h.linewidth = 1 I am not sure about the side-effects of this -- the problem is this breaks classes that use instance-level attributes with the same names as the setters and getters (e.g. if an artist subclass both the getter get_linewidth() and the literal attribute linewidth), and the only way to address this is to go through the source code class-by-class and make explicit exceptions (which is quite fragile, since the attributes may change from version-to-version). Monkey patching is not possible because you cannot add properties as instance-level attributes. This is a really neat PR, but it will require a lot of testing and it's not as high priority as some other PRs. So it may be quite a while before this is merged.
Open Graph Description: This PR is related to #89 and adds @property setters and getters to every single Artist subclass. The core logic for this turns out to be surprisingly simple: https://github.com/lukelbd/proplot/bl...
X Description: This PR is related to #89 and adds @property setters and getters to every single Artist subclass. The core logic for this turns out to be surprisingly simple: https://github.com/lukelbd/proplot/bl...
Opengraph URL: https://github.com/proplot-dev/proplot/pull/168
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:688ac134-9de8-f86d-f4be-733e06c84484 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D3F2:239CAA:E9FFF:13A349:697AED1A |
| html-safe-nonce | a2912a802e27c86b6137e948b72674ba5681ea9e5f0a5de281509a8b1df9dacb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0YyOjIzOUNBQTpFOUZGRjoxM0EzNDk6Njk3QUVEMUEiLCJ2aXNpdG9yX2lkIjoiMjc0NzgwNjEzNjU2MzA2ODE4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c1226d87fdf81d7a3449dced690b879ec2d4db6d00d900c8c02a6b0cd68f4ba8 |
| hovercard-subject-tag | pull_request:418914017 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/proplot-dev/proplot/pull/168/files |
| twitter:image | https://avatars.githubusercontent.com/u/19657652?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/19657652?s=400&v=4 |
| og:image:alt | This PR is related to #89 and adds @property setters and getters to every single Artist subclass. The core logic for this turns out to be surprisingly simple: https://github.com/lukelbd/proplot/bl... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7ce8ed0a54c4730aeca4e6abacfc6490365fc42e25480b86883054df3f9181c8 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/proplot-dev/proplot git https://github.com/proplot-dev/proplot.git |
| octolytics-dimension-user_id | 108025793 |
| octolytics-dimension-user_login | proplot-dev |
| octolytics-dimension-repository_id | 113293661 |
| octolytics-dimension-repository_nwo | proplot-dev/proplot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 113293661 |
| octolytics-dimension-repository_network_root_nwo | proplot-dev/proplot |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d7bfc78137af9a4828305e52ab993fce981d7085 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width