Title: Move away from set_ticklabels() · Issue #19016 · matplotlib/matplotlib · GitHub
Open Graph Title: Move away from set_ticklabels() · Issue #19016 · matplotlib/matplotlib
X Title: Move away from set_ticklabels() · Issue #19016 · matplotlib/matplotlib
Description: This is a placeholder issue so that I don't forget about it. I will some time later implement a draft PR. However, feedback is already welcome. Problem statement Axis.set_ticklabels() (and the derived Axes.set_x/yticklabels()) are proble...
Open Graph Description: This is a placeholder issue so that I don't forget about it. I will some time later implement a draft PR. However, feedback is already welcome. Problem statement Axis.set_ticklabels() (and the deri...
X Description: This is a placeholder issue so that I don't forget about it. I will some time later implement a draft PR. However, feedback is already welcome. Problem statement Axis.set_ticklabels() (and the ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19016
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Move away from set_ticklabels()","articleBody":"*This is a placeholder issue so that I don't forget about it. I will some time later implement a draft PR. However, feedback is already welcome.*\r\n\r\n### Problem statement\r\n\r\n`Axis.set_ticklabels()` (and the derived `Axes.set_x/yticklabels()`) are problematic as they change the text of existing ticks. This relies implicitly on ticks being set previously at adequate positions. Essentially `set_ticklabels()` can only be used reasonably if `set_ticks()` has been called before. We try to make users aware of this by a warning in https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.axis.Axis.set_ticklabels.html.\r\n\r\n### Proposed fix\r\n\r\n1. Add a parameter `labels` to `Axis.set_ticks()` so that one can do\r\n ~~~\r\n ax.set_xticks([1, 2, 3], labels=['a', 'b', 'c'])\r\n ~~~\r\n instead of\r\n ~~~\r\n ax.set_xticks([1, 2, 3])\r\n ax.set_xticklabels(['a', 'b', 'c'])\r\n ~~~\r\n\r\n2. Discourage using `set_ticklabels()`. - I think it's too widely used, so that we cannot deprecate it.\r\n\r\n### Further comments\r\n\r\nThis should make `set_xticks()` more similar/equal to `pyplot.xticks()`, which already has the labels parameter.\r\n\r\nTo be sorted out:\r\n- whether we want to support labels only (set_ticks(labels=['a', 'b', 'c'])\r\n- the return value of `get_xicks()`, which only returns the values, whereas `pyplot.xticks()` without parameters returns `ticks, labels`. This is a somwhat annoying asymmetry, but probably has to be left as is.\r\n- some more details.","author":{"url":"https://github.com/timhoffm","@type":"Person","name":"timhoffm"},"datePublished":"2020-11-26T01:36:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/19016/matplotlib/issues/19016"}
| 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:3cd221a4-90df-72df-dcbe-8de96b19d0ac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC26:20E8B8:8F96F5:C4F315:6A539410 |
| html-safe-nonce | 6210a2c2cb45a303f5f6767b6e4f87b281368a179e52a3885009705557a9ac48 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzI2OjIwRThCODo4Rjk2RjU6QzRGMzE1OjZBNTM5NDEwIiwidmlzaXRvcl9pZCI6IjE0OTY4MzA3NTYyMzYwMDY0MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 61b06f48d04b31fa87922b7590c27b37f265cfcd3c913ad08f4f4b11c7358793 |
| hovercard-subject-tag | issue:751216420 |
| 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/19016/issue_layout |
| twitter:image | https://opengraph.githubassets.com/14678efb51e8f43e89975e599294df9fbb707fd91aa673db2feae3b332068536/matplotlib/matplotlib/issues/19016 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/14678efb51e8f43e89975e599294df9fbb707fd91aa673db2feae3b332068536/matplotlib/matplotlib/issues/19016 |
| og:image:alt | This is a placeholder issue so that I don't forget about it. I will some time later implement a draft PR. However, feedback is already welcome. Problem statement Axis.set_ticklabels() (and the deri... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timhoffm |
| 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