Title: Twinned axes do not allow setting of different formatters · Issue #7376 · matplotlib/matplotlib · GitHub
Open Graph Title: Twinned axes do not allow setting of different formatters · Issue #7376 · matplotlib/matplotlib
X Title: Twinned axes do not allow setting of different formatters · Issue #7376 · matplotlib/matplotlib
Description: To help us understand and resolve your issue please check that you have provided the information below. Matplotlib version, Python version and Platform (Windows, OSX, Linux ...) Matplotlib 1.51, Python 3.5.2 on Red Hat Enterprise Linux 6...
Open Graph Description: To help us understand and resolve your issue please check that you have provided the information below. Matplotlib version, Python version and Platform (Windows, OSX, Linux ...) Matplotlib 1.51, Py...
X Description: To help us understand and resolve your issue please check that you have provided the information below. Matplotlib version, Python version and Platform (Windows, OSX, Linux ...) Matplotlib 1.51, Py...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/7376
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Twinned axes do not allow setting of different formatters","articleBody":"To help us understand and resolve your issue please check that you have provided\r\nthe information below.\r\n\r\n- [x] Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)\r\nMatplotlib 1.51, Python 3.5.2 on Red Hat Enterprise Linux 6.5\r\n\r\n- [x] How did you install Matplotlib and Python (pip, anaconda, from source ...)\r\nAnaconda 1.5.1 (conda 4.2.9)\r\n\r\n- [x] If possible please supply a [Short, Self Contained, Correct, Example](http://sscce.org/)\r\n that demonstrates the issue i.e a small piece of code which reproduces the issue\r\n and can be run with out any other (or as few as possible) external dependencies.\r\n```python\r\nfrom matplotlib import pyplot as plt\r\nfrom matplotlib.ticker import Formatter, MaxNLocator\r\n\r\nax = plt.plot([0, 1, 2, 3], [0, 1, 2, 3])[0].axes\r\nax.figure.subplots_adjust(bottom=0.3)\r\nax.set_xlabel('Axis1') # To demonstrate that labels can be set differently\r\nax2 = ax.twinx()\r\nax2.set_frame_on(True)\r\nax2.patch.set_visible(False)\r\nax2.yaxis.set_visible(False)\r\nax2.xaxis.set_visible(True)\r\nax2.spines['bottom'].set_position(('axes', -0.2)) # So far so good\r\nax2.set_xlabel('Axis2') # Surprisingly (or not), this works\r\n\r\nclass F(Formatter):\r\n def __call__(self, x, pos=None):\r\n return '%03d' % x\r\n\r\n# This does not work as expected:\r\nax.xaxis.set_major_locator(MaxNLocator(integer=True)) # Both locators get modified\r\nax2.xaxis.set_major_formatter(F()) # Both formatters get modified\r\n```\r\n\r\nI suspect that this has something to do with the fact that `Axis` has a `Ticker` container for the attributes that are behaving inappropriately, and that they are not being copied correctly when the axis is twinned for some reason. I have not been able to trace this problem down yet, but with a few pointer from the experts, I'd probably be able to make a PR. Assuming this is actually an issue, of course.\r\n\r\n- [ ] If this is an image generation bug attach a screenshot demonstrating the issue.\r\n- [ ] If this is a regression (Used to work in an earlier version of Matplotlib), please \r\n note where it used to work.\r\n","author":{"url":"https://github.com/madphysicist","@type":"Person","name":"madphysicist"},"datePublished":"2016-11-01T21:53:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/7376/matplotlib/issues/7376"}
| 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:32f4eab2-945e-82a4-e271-bfa36d8ec162 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DBAE:917F8:10988B0:16242B4:6A5334D4 |
| html-safe-nonce | dbfe40c180a1793a032c829c20a35ae8d4d1c80820909d4874784b559e9bfaa6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQkFFOjkxN0Y4OjEwOTg4QjA6MTYyNDJCNDo2QTUzMzRENCIsInZpc2l0b3JfaWQiOiIxODkxMDAxNzYyMDc4NDcxMzgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c31dccb2ac1060ff7a247979014ff79723ad8912bcc093b52de7287f9db8fc8f |
| hovercard-subject-tag | issue:186658269 |
| 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/7376/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b028001c46e520177576ad4ad76e4492bbcbdf2214f73565c59d8be6b5840607/matplotlib/matplotlib/issues/7376 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b028001c46e520177576ad4ad76e4492bbcbdf2214f73565c59d8be6b5840607/matplotlib/matplotlib/issues/7376 |
| og:image:alt | To help us understand and resolve your issue please check that you have provided the information below. Matplotlib version, Python version and Platform (Windows, OSX, Linux ...) Matplotlib 1.51, Py... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | madphysicist |
| 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