Title: Incorrect labels returned with custom formatter and locator · Issue #9397 · matplotlib/matplotlib · GitHub
Open Graph Title: Incorrect labels returned with custom formatter and locator · Issue #9397 · matplotlib/matplotlib
X Title: Incorrect labels returned with custom formatter and locator · Issue #9397 · matplotlib/matplotlib
Description: In the following example I am getting back the wrong labels from ax.xaxis.get_ticklabels: import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter, MaxNLocator ax = plt.subplot(1,1,1) def formatter_func(pos, *args): re...
Open Graph Description: In the following example I am getting back the wrong labels from ax.xaxis.get_ticklabels: import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter, MaxNLocator ax = plt.subplot(1...
X Description: In the following example I am getting back the wrong labels from ax.xaxis.get_ticklabels: import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter, MaxNLocator ax = plt.subplot(1...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9397
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect labels returned with custom formatter and locator","articleBody":"In the following example I am getting back the wrong labels from ``ax.xaxis.get_ticklabels``:\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.ticker import FuncFormatter, MaxNLocator\r\n\r\nax = plt.subplot(1,1,1)\r\n\r\ndef formatter_func(pos, *args):\r\n return 'a' if pos == 1 else ''\r\n\r\nax.figure.canvas.draw()\r\nprint([tick.get_text() for tick in ax.xaxis.get_ticklabels()])\r\n\r\nax.xaxis.set_major_formatter(FuncFormatter(formatter_func))\r\nax.xaxis.set_major_locator(MaxNLocator(10, integer=True))\r\n\r\nax.set_xlim(-0.5, 2.5)\r\n\r\nax.figure.canvas.draw()\r\nprint([tick.get_text() for tick in ax.xaxis.get_ticklabels()])\r\n```\r\n\r\nThis gives:\r\n\r\n```\r\n['0.0', '0.2', '0.4', '0.6', '0.8', '1.0']\r\n['0.0', '', 'a', '', '0.8']\r\n```\r\n\r\nwhereas I expected:\r\n\r\n```\r\n['0.0', '0.2', '0.4', '0.6', '0.8', '1.0']\r\n['', '', 'a', '', '']\r\n```","author":{"url":"https://github.com/astrofrog","@type":"Person","name":"astrofrog"},"datePublished":"2017-10-13T21:52:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/9397/matplotlib/issues/9397"}
| 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:355d8016-afc5-3d61-85b3-98e91c478c2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD70:12716:B79FA2:FB838B:6A55B78F |
| html-safe-nonce | 3b36a0e150039fc857a11ef315c402535c1fe6c041ca04472bf6aa9bf724cafe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDcwOjEyNzE2OkI3OUZBMjpGQjgzOEI6NkE1NUI3OEYiLCJ2aXNpdG9yX2lkIjoiODY2MzczNDcwMzI5ODU1NzgzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4735394b095bfe7af9ee5a8a93576139f136479b078dcb7dbc6b08137d34cb54 |
| hovercard-subject-tag | issue:265428660 |
| 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/9397/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2c54d74be6faa4c203f0ad057b46b78b0c7382b34d8ed09da0700f0bb09eaa9/matplotlib/matplotlib/issues/9397 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2c54d74be6faa4c203f0ad057b46b78b0c7382b34d8ed09da0700f0bb09eaa9/matplotlib/matplotlib/issues/9397 |
| og:image:alt | In the following example I am getting back the wrong labels from ax.xaxis.get_ticklabels: import matplotlib.pyplot as plt from matplotlib.ticker import FuncFormatter, MaxNLocator ax = plt.subplot(1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | astrofrog |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 64b9ae238e18eb87ead1f9fe37a7cc81d67d85aa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width