Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdf5399

Browse files
authored
Merge pull request #25841 from anntzer/usl
Deprecate Tick.set_label{1,2}.
2 parents e4a7ef3 + b31fd9c commit bdf5399

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``Tick.set_label1`` and ``Tick.set_label2``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated. Calling these methods from third-party code usually has no
4+
effect, as the labels are overwritten at draw time by the tick formatter.

lib/matplotlib/axis.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def draw(self, renderer):
291291
renderer.close_group(self.__name__)
292292
self.stale = False
293293

294+
@_api.deprecated("3.8")
294295
def set_label1(self, s):
295296
"""
296297
Set the label1 text.
@@ -304,6 +305,7 @@ def set_label1(self, s):
304305

305306
set_label = set_label1
306307

308+
@_api.deprecated("3.8")
307309
def set_label2(self, s):
308310
"""
309311
Set the label2 text.
@@ -1250,15 +1252,15 @@ def _update_ticks(self):
12501252
major_ticks = self.get_major_ticks(len(major_locs))
12511253
for tick, loc, label in zip(major_ticks, major_locs, major_labels):
12521254
tick.update_position(loc)
1253-
tick.set_label1(label)
1254-
tick.set_label2(label)
1255+
tick.label1.set_text(label)
1256+
tick.label2.set_text(label)
12551257
minor_locs = self.get_minorticklocs()
12561258
minor_labels = self.minor.formatter.format_ticks(minor_locs)
12571259
minor_ticks = self.get_minor_ticks(len(minor_locs))
12581260
for tick, loc, label in zip(minor_ticks, minor_locs, minor_labels):
12591261
tick.update_position(loc)
1260-
tick.set_label1(label)
1261-
tick.set_label2(label)
1262+
tick.label1.set_text(label)
1263+
tick.label2.set_text(label)
12621264
ticks = [*major_ticks, *minor_ticks]
12631265

12641266
view_low, view_high = self.get_view_interval()

0 commit comments

Comments
 (0)