Title: add_subplot(..., axes_cls=...) · Issue #18548 · matplotlib/matplotlib · GitHub
Open Graph Title: add_subplot(..., axes_cls=...) · Issue #18548 · matplotlib/matplotlib
X Title: add_subplot(..., axes_cls=...) · Issue #18548 · matplotlib/matplotlib
Description: I would like to suggest adding an axes_cls parameter to add_subplot()/add_axes(), to support creating axes using custom Axes subclasses -- specifically with the idea of better integrating axes_grid/axisartist into Matplotlib. Currently, ...
Open Graph Description: I would like to suggest adding an axes_cls parameter to add_subplot()/add_axes(), to support creating axes using custom Axes subclasses -- specifically with the idea of better integrating axes_grid...
X Description: I would like to suggest adding an axes_cls parameter to add_subplot()/add_axes(), to support creating axes using custom Axes subclasses -- specifically with the idea of better integrating axes_grid...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18548
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"add_subplot(..., axes_cls=...)","articleBody":"I would like to suggest adding an `axes_cls` parameter to `add_subplot()`/`add_axes()`, to support creating axes using custom Axes subclasses -- specifically with the idea of better integrating axes_grid/axisartist into Matplotlib.\r\n\r\nCurrently, using an axes_grid/axisartist Axes requires a rather unusual sequence of calls, of the form\r\n```python\r\nfrom mpl_toolkits.\u003c...\u003e import SomeAxesSubclass\r\nax = SomeAxesSubclass(fig, 111, **kwargs)\r\nfig.add_subplot(ax) # It's quite rare to call add_subplot() with an Axes instance!\r\n```\r\ninstead, I propose that one can simply write\r\n```python\r\nfrom mpl_toolkits.\u003c...\u003e import SomeAxesSubclass\r\nax = fig.add_subplot(1, 1, 1, axes_cls=SomeAxesSubclass, **kwargs)\r\n# or, in the common case (add_subplot defaults to 111):\r\nax = fig.add_subplot(axes_cls=SomeAxesSubclass, **kwargs)\r\n```\r\n\r\nNote that there is precedence in that `plt.figure` likewise takes a `FigureClass` argument for custom figure subclasses. (If we wanted to be consistent we could name the new kwarg `AxesClass` instead of `axes_cls`, but... ugh.) Also note that `axes_class` would conflict with the `projection` kwarg, because projections (e.g. polar) are also implemented as custom axes subclasses, but that's just how things are: you can't automatically combine a mpl_toolkits subclass with a projection subclass.\r\n\r\nSee also https://github.com/matplotlib/matplotlib/pull/17335#issuecomment-625070659.\r\n\r\nOne side advantage is that this would also make all the explicit Subplot classes (HostAxes vs. SubplotHost, axislines.Subplot vs. axislines.Axes) unnecessary: add_subplot would dynamically create the subclasses, with exactly the same machinery as it does for the normal Axes/Subplot.\r\n\r\nI don't think the implementation will be particularly hard; as usual the hardest is deciding whether we want this or not :-)","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2020-09-23T09:18:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/18548/matplotlib/issues/18548"}
| 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:7e175b43-c59f-8cd0-140e-c8ad7dbe7d80 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8882:3258B1:B64C3B:F38439:6A52BA62 |
| html-safe-nonce | 700ec214e582d4a848c2a914e6827c8d4b03cb4f9cec8016baa474a9d85471d5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODgyOjMyNThCMTpCNjRDM0I6RjM4NDM5OjZBNTJCQTYyIiwidmlzaXRvcl9pZCI6Ijc1NjQ4NzEzNjIxODA5ODc0OTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3e0e01c48469df9f6839f7612a3c67b3b0ff81d281aa64734b845dcb65e8c881 |
| hovercard-subject-tag | issue:707193602 |
| 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/18548/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ae410d15789895943efe08f9a9e98d91287648acd985c33c36e8096cef48901f/matplotlib/matplotlib/issues/18548 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ae410d15789895943efe08f9a9e98d91287648acd985c33c36e8096cef48901f/matplotlib/matplotlib/issues/18548 |
| og:image:alt | I would like to suggest adding an axes_cls parameter to add_subplot()/add_axes(), to support creating axes using custom Axes subclasses -- specifically with the idea of better integrating axes_grid... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width