8000 Deprecate Tick.set_label{1,2}. by anntzer · Pull Request #25841 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
8000

Deprecate Tick.set_label{1,2}. #25841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/25841-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``Tick.set_label1`` and ``Tick.set_label2``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... are deprecated. Calling these methods from third-party code usually has no
effect, as the labels are overwritten at draw time by the tick formatter.
10 changes: 6 additions & 4 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def draw(self, renderer):
renderer.close_group(self.__name__)
self.stale = False

@_api.deprecated("3.8")
def set_label1(self, s):
"""
Set the label1 text.
Expand All @@ -304,6 +305,7 @@ def set_label1(self, s):

set_label = set_label1

@_api.deprecated("3.8")
def set_label2(self, s):
"""
Set the label2 text.
Expand Down Expand Up @@ -1250,15 +1252,15 @@ def _update_ticks(self):
major_ticks = self.get_major_ticks(len(major_locs))
for tick, loc, label in zip(major_ticks, major_locs, major_labels):
tick.update_position(loc)
tick.set_label1(label)
tick.set_label2(label)
tick.label1.set_text(label)
tick.label2.set_text(label)
minor_locs = self.get_minorticklocs()
minor_labels = self.minor.formatter.format_ticks(minor_locs)
minor_ticks = self.get_minor_ticks(len(minor_locs))
for tick, loc, label in zip(minor_ticks, minor_locs, minor_labels):
tick.update_position(loc)
tick.set_label1(label)
tick.set_label2(label)
tick.label1.set_text(label)
tick.label2.set_text(label)
ticks = [*major_ticks, *minor_ticks]

view_low, view_high = self.get_view_interval()
Expand Down
0