-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Move away from set_ticklabels() #19016
Copy link
Copy link
Closed
Labels
API: changesChanges to the public API, typically requiring deprecation.Changes to the public API, typically requiring deprecation.API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …Maintenance
Milestone
Metadata
Metadata
Assignees
Labels
API: changesChanges to the public API, typically requiring deprecation.Changes to the public API, typically requiring deprecation.API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …Maintenance
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 derivedAxes.set_x/yticklabels()) are problematic as they change the text of existing ticks. This relies implicitly on ticks being set previously at adequate positions. Essentiallyset_ticklabels()can only be used reasonably ifset_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.Proposed fix
Add a parameter
labelstoAxis.set_ticks()so that one can doinstead of
Discourage using
set_ticklabels(). - I think it's too widely used, so that we cannot deprecate it.Further comments
This should make
set_xticks()more similar/equal topyplot.xticks(), which already has the labels parameter.To be sorted out:
get_xicks(), which only returns the values, whereaspyplot.xticks()without parameters returnsticks, labels. This is a somwhat annoying asymmetry, but probably has to be left as is.