Title: Have Colorbar inherit from Axes · Issue #20341 · matplotlib/matplotlib · GitHub
Open Graph Title: Have Colorbar inherit from Axes · Issue #20341 · matplotlib/matplotlib
X Title: Have Colorbar inherit from Axes · Issue #20341 · matplotlib/matplotlib
Description: Describe the issue A Colorbar currently stores the Axes that is used for drawing in the cbar.ax attribute, which many of the methods are then called internally like self.ax.pcolormesh(). My proposal is to move the Axes up a level and hav...
Open Graph Description: Describe the issue A Colorbar currently stores the Axes that is used for drawing in the cbar.ax attribute, which many of the methods are then called internally like self.ax.pcolormesh(). My proposa...
X Description: Describe the issue A Colorbar currently stores the Axes that is used for drawing in the cbar.ax attribute, which many of the methods are then called internally like self.ax.pcolormesh(). My proposa...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20341
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Have Colorbar inherit from Axes","articleBody":"### Describe the issue\r\n\r\nA Colorbar currently stores the Axes that is used for drawing in the `cbar.ax` attribute, which many of the methods are then called internally like `self.ax.pcolormesh()`. My proposal is to move the Axes up a level and have Colorbar inherit from the new `CbarAxes` class (to become an Axes itself) and turn the previous call into `self.pcolormesh()` dropping `ax` attribute.\r\n\r\n**Benefits:** This would help with interactivity as proposed in #19515, by being able to identify if an axes is a Colorbar or not and then controlling properties based on that. It would also help with #20330, by giving the CbarAxes the ability to remove colorbar callbacks.\r\n\r\n**Drawbacks:** This adds a lot of easy-to-use methods onto a Colorbar now that may not be desired to directly expose to users. i.e. they could do `cbar.plot()` now, whereas before `cbar.ax.plot()` hides those capabilities a little bit more.\r\n\r\n### Proposed fix\r\n\r\nDefine the class as\r\n`class ColorbarBase(ColorbarAxes):`\r\n\r\nand set\r\n`self.ax = self` for people to keep using `cbar.ax` if they prefer. We could deprecate that on pass-through as well.\r\n\r\nSee [this branch](https://github.com/greglucas/matplotlib/tree/colorbar-inherit-axes) for an implementation.","author":{"url":"https://github.com/greglucas","@type":"Person","name":"greglucas"},"datePublished":"2021-06-02T03:23:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/20341/matplotlib/issues/20341"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:adbaab6f-cda1-8acc-04c0-ffff0c28feb2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CCAC:3AC7E6:1815A8D:1FD7EF9:6A51C402 |
| html-safe-nonce | 021877e398237b225b3fbfbe8d59fc069ec7592562535c722ecba7f341d4912b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0FDOjNBQzdFNjoxODE1QThEOjFGRDdFRjk6NkE1MUM0MDIiLCJ2aXNpdG9yX2lkIjoiNDA5NzUzNzczNTc2OTgzNDQ5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 666f1b5be0f188ae8f08e197db7df1306cf9257e6ec986f3cc768ae7fc0532b2 |
| hovercard-subject-tag | issue:909044382 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/matplotlib/matplotlib/20341/issue_layout |
| twitter:image | https://opengraph.githubassets.com/405ee500a7e92eb82b68f218ca55aada5b04c6abb7b7e815e54cbe736f61437e/matplotlib/matplotlib/issues/20341 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/405ee500a7e92eb82b68f218ca55aada5b04c6abb7b7e815e54cbe736f61437e/matplotlib/matplotlib/issues/20341 |
| og:image:alt | Describe the issue A Colorbar currently stores the Axes that is used for drawing in the cbar.ax attribute, which many of the methods are then called internally like self.ax.pcolormesh(). My proposa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | greglucas |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width