Title: ENH: Added share_tickers parameter to axes._AxesBase.twinx/y by madphysicist · Pull Request #7528 · matplotlib/matplotlib · GitHub
Open Graph Title: ENH: Added share_tickers parameter to axes._AxesBase.twinx/y by madphysicist · Pull Request #7528 · matplotlib/matplotlib
X Title: ENH: Added share_tickers parameter to axes._AxesBase.twinx/y by madphysicist · Pull Request #7528 · matplotlib/matplotlib
Description: Allow a copy of Axis.minor and Axis.major objects to be made when axes are twinned. This will allow two twinned axes to have different Formatter and Locator objects when they are both visible. The default of always sharing the same references (via a shared matplotlib.axis.Ticker container) has been preserved. I made the keyword parameter share_tickers propagate all the way to axes._AxesBase.__init__ rather than implementing the copy in axes.AxesBase._make_twin_axes. The reason is that I would like to be able to modify the meaning of sharex and sharey directly in the constructor. Fixes #7376. This PR includes tests. A couple of places that I would ask reviewers to look at: I made one functional change that I think is OK, but may need to be reverted. In axes/_base.py, around line 1004, where the formatter and locator get reset, the original code called Axis.set_major/minor_formatter/locator. This would set the axis attribute of the locators and formatters to the second axis, not the original one that twinx/y was called on in the first place. I have gone ahead and changed that behavior for both the shared_ticker=True case and the False case. For the False case this is pretty obvious, since we do not want to change the axis attribute of the original formatter and locator at all. It should not cause any problems in the True case either, but it is technically a minor change in the functionality that I would like to bring attention to. Did I add documentation for the share_tickers parameter correctly in axes/_base.py:473? Did I add the handling of the parameter correctly? Specifically, it will affect the axis key in Figure._make_key. I think that this is correct because the axes with and without share_tickers will serve different purposes visually, so it should be OK to treat them as different objects. I did not add an explicit test for the new copy constructor of axis.Ticker because it is really trivial. However, the code does get complete coverage in the tests that I wrote for twinx/y.
Open Graph Description: Allow a copy of Axis.minor and Axis.major objects to be made when axes are twinned. This will allow two twinned axes to have different Formatter and Locator objects when they are both visible. The ...
X Description: Allow a copy of Axis.minor and Axis.major objects to be made when axes are twinned. This will allow two twinned axes to have different Formatter and Locator objects when they are both visible. The ...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/7528
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6d29de43-939e-f279-3ae9-8a13ab3a1064 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CF6C:288A2A:354CC5:468AA2:6A53E2D3 |
| html-safe-nonce | 3a40333ecf97c90e1a4d24587d57864f0339077509795bfcb78aed57ac3feb05 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjZDOjI4OEEyQTozNTRDQzU6NDY4QUEyOjZBNTNFMkQzIiwidmlzaXRvcl9pZCI6Ijg2NTIxMDEwMDI2OTMxNzM5NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c45297282500cdfbc2dbfa61533d2d2c44863815af7f757470c4ce07fd304a80 |
| hovercard-subject-tag | pull_request:95592621 |
| 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/matplotlib/matplotlib/pull/7528/files |
| twitter:image | https://avatars.githubusercontent.com/u/4617010?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4617010?s=400&v=4 |
| og:image:alt | Allow a copy of Axis.minor and Axis.major objects to be made when axes are twinned. This will allow two twinned axes to have different Formatter and Locator objects when they are both visible. The ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width