Title: [MNT]: Consolidate tick API · Issue #29594 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: Consolidate tick API · Issue #29594 · matplotlib/matplotlib
X Title: [MNT]: Consolidate tick API · Issue #29594 · matplotlib/matplotlib
Description: Summary The Tick class/concept consistents of a ticklabel, a tickline (the marker) and a gridline. In addition there's the location as a fundmental property. We have a lot of methods to handle ticks. There are methods on Axis to configur...
Open Graph Description: Summary The Tick class/concept consistents of a ticklabel, a tickline (the marker) and a gridline. In addition there's the location as a fundmental property. We have a lot of methods to handle tick...
X Description: Summary The Tick class/concept consistents of a ticklabel, a tickline (the marker) and a gridline. In addition there's the location as a fundmental property. We have a lot of methods to handle ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29594
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: Consolidate tick API","articleBody":"### Summary\n\nThe Tick class/concept consistents of a *ticklabel*, a *tickline* (the marker) and a *gridline*. In addition there's the *location* as a fundmental property.\n\nWe have a lot of methods to handle ticks. There are methods on Axis to configure all these properties - often in flavors of major/minor and global (i.e. a function that lets you select major/minor/both). These methods would typically be used via `ax.xaxis.get_majorticklabels()`. Additionally, a subset of these wrappers is exposed on the Axes level, then in the flavors of x/y.\n\n\n\nOverall we have 16 such methods on Axes and 14 on Axis that directly work on Tick instances or parts of them.\n\n### Proposed fix\n\nWe should discourage direct interaction with ticks or their components (ticklabel, tickline, gridline). As ticks are volatile configuring the instances explicitly may not persist if the plot is changed later.\n\nTherefore, I would like to get rid of the high-level Axes methods that give access to these components: `get_xticklabels()`, `get_xmajorticklabels()`, `get_xminorticklabels()`, `get_xgridlines()`, `get_xticklines()` (and same for y).\n\nPeople should use `tick_params()` instead where possible, e.g. `ax.tick_params(labelsize=10)` instead of `for label in ax.get_xticklabels(): label.set_fontsize(10)`. This is not only shorter but also configures the common/universal tick property instead of individual volatile instances.\nSince `tick_params()` does currently not, and likely will never provide full control on all aspects (e.g. [this example](https://matplotlib.org/stable/gallery/event_handling/pick_event_demo.html#simple-picking-lines-rectangles-and-text) makes tick labels pickable), users should use the underlying Axis functions if they really must access the indivdual tick(components), i.e. use `ax.xaxis.get_ticklabels()` instead of ax.get_xticklabels()`.\n\nWhile removing this bunch of wrapper functions on Axes is massive API change, I think we eventually want to go there (slowly through a pending deprecation), because these functions are encouraging nowadays bad practice. - The weaker alternative would be to only discourage.\n\nConcrete:\n- pending deprecate the `Axes` methods: `get_xticklabels()`, `get_xmajorticklabels()`, `get_xminorticklabels()`, `get_xgridlines()`, `get_xticklines()` (and same for y).\n- Recommend to use `Axes.tick_params()` instead where possible.\n- Recommend to ues the respective `Axis` methods if more control is needed, e.g. `ax.xaxis.get_ticklabels()`\n- On all methods that return Tick components, warn that this only affects the current instances and future changes to the plot may create new ticks.\n\n---\nUsage statistics from GitHub query\nQuery string: `/\\.get_gridlines\\(/ NOT path:_base.py NOT path:axes.py NOT path:axis.py language:Python NOT is:fork NOT repo:matplotlib/matplotlib`\n\n","author":{"url":"https://github.com/timhoffm","@type":"Person","name":"timhoffm"},"datePublished":"2025-02-08T09:38:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/29594/matplotlib/issues/29594"}
| 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:7899c364-504f-9346-ea01-5def5e7d130a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE2A:E05E1:636B7:827A1:6A526987 |
| html-safe-nonce | 9bbce82cbdea25cb5e788cffaa18580aa3f259c6c54acef9eba16b65a2635605 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTJBOkUwNUUxOjYzNkI3OjgyN0ExOjZBNTI2OTg3IiwidmlzaXRvcl9pZCI6IjMwMjE3NzIzODA4NzgwMzk0MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d56188b9cb9eccb5eadd70059673bb88788189a3c437046c53ccd9fddd8c8948 |
| hovercard-subject-tag | issue:2839742378 |
| 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/29594/issue_layout |
| twitter:image | https://opengraph.githubassets.com/179bc211d875570bfbb4267dd7c2f2b908012b2a2ada2793724a29ffc225788e/matplotlib/matplotlib/issues/29594 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/179bc211d875570bfbb4267dd7c2f2b908012b2a2ada2793724a29ffc225788e/matplotlib/matplotlib/issues/29594 |
| og:image:alt | Summary The Tick class/concept consistents of a ticklabel, a tickline (the marker) and a gridline. In addition there's the location as a fundmental property. We have a lot of methods to handle tick... |
| 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