From b31fd9ce6acc30e8e65c95b068da51fd870f0407 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 9 May 2023 19:13:20 +0200 Subject: [PATCH] Deprecate Tick.set_label{1,2}. ... as detailed in the deprecation notice. --- doc/api/next_api_changes/deprecations/25841-AL.rst | 4 ++++ lib/matplotlib/axis.py | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/25841-AL.rst diff --git a/doc/api/next_api_changes/deprecations/25841-AL.rst b/doc/api/next_api_changes/deprecations/25841-AL.rst new file mode 100644 index 000000000000..70ebc012ab44 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/25841-AL.rst @@ -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. diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index eb393f89882d..a9b216bd84a6 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -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. @@ -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. @@ -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()