8000 Deprecate Tick.apply_tickdir. · matplotlib/matplotlib@69f7ec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 69f7ec7

Browse files
committed
Deprecate Tick.apply_tickdir.
apply_tickdir doesn't actually update the tick markers on the existing Line2D objects used to draw the ticks (as can be checked with e.g. `plt.gca().xaxis.majorTicks[2].apply_tickdir("inout")`), so it's really mostly an internal helper that cannot be meaningfully called from outside (it needs to cooperate with `_apply_params` to actually work).
1 parent 71c9f09 commit 69f7ec7

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

doc/api/axis_api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ specify a matching series of labels. Calling ``set_ticks`` makes a
266266
:template: autosummary.rst
267267
:nosignatures:
268268

269-
270-
Tick.apply_tickdir
271269
Tick.get_loc
272270
Tick.get_pad
273271
Tick.get_pad_pixels
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``Tick.apply_tickdir`` is deprecated
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
``apply_tickdir`` didn't actually update the tick markers on the existing
5+
Line2D objects used to draw the ticks; use `.Axis.set_tick_params` instead.

lib/matplotlib/axis.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __init__(self, axes, loc, label=None,
148148
grid_alpha = mpl.rcParams["grid.alpha"]
149149
grid_kw = {k[5:]: v for k, v in kw.items()}
150150

151-
self.apply_tickdir(tickdir)
151+
self._apply_tickdir(tickdir)
152152

153153
self.tick1line = mlines.Line2D(
154154
[], [],
@@ -209,15 +209,18 @@ def _set_labelrotation(self, labelrotation):
209209
_api.check_in_list(['auto', 'default'], labelrotation=mode)
210210
self._labelrotation = (mode, angle)
211211

212-
def apply_tickdir(self, tickdir):
212+
def _apply_tickdir(self, tickdir):
213213
"""Set tick direction. Valid values are 'out', 'in', 'inout'."""
214+
# Overriding subclasses should also compute _tickmarkers here.
214215
if tickdir is None:
215216
tickdir = mpl.rcParams[f'{self.__name__}.direction']
216217
_api.check_in_list(['in', 'out', 'inout'], tickdir=tickdir)
217218
self._tickdir = tickdir
218219
self._pad = self._base_pad + self.get_tick_padding()
219220
self.stale = True
220-
# Subclass overrides should compute _tickmarkers as appropriate here.
221+
222+
apply_tickdir = _api.deprecate_privatize_attribute(
223+
"3.5", alternative="axis.set_tick_params")
221224

222225
def get_tickdir(self):
223226
return self._tickdir
@@ -363,15 +366,15 @@ def _apply_params(self, **kw):
363366
# convenient to leave it here.
364367
self._width = kw.pop('width', self._width)
365368
self._base_pad = kw.pop('pad', self._base_pad)
366-
# apply_tickdir uses _size and _base_pad to make _pad,
369+
# _apply_tickdir uses _size and _base_pad to make _pad,
367370
# and also makes _tickmarkers.
368-
self.apply_tickdir(kw.pop('tickdir', self._tickdir))
371+
self._apply_tickdir(kw.pop('tickdir', self._tickdir))
369372
self.tick1line.set_marker(self._tickmarkers[0])
370373
self.tick2line.set_marker(self._tickmarkers[1])
371374
for line in (self.tick1line, self.tick2line):
372375
line.set_markersize(self._size)
373376
line.set_markeredgewidth(self._width)
374-
# _get_text1_transform uses _pad from apply_tickdir.
377+
# _get_text1_transform uses _pad from _apply_tickdir.
375378
trans = self._get_text1_transform()[0]
376379
self.label1.set_transform(trans)
377380
trans = self._get_text2_transform()[0]
@@ -451,9 +454,9 @@ def _get_text1_transform(self):
451454
def _get_text2_transform(self):
452455
return self.axes.get_xaxis_text2_transform(self._pad)
453456

454-
def apply_tickdir(self, tickdir):
457+
def _apply_tickdir(self, tickdir):
455458
# docstring inherited
456-
super().apply_tickdir(tickdir)
459+
super()._apply_tickdir(tickdir)
457460
self._tickmarkers = {
458461
'out': (mlines.TICKDOWN, mlines.TICKUP),
459462
'in': (mlines.TICKUP, mlines.TICKDOWN),
@@ -518,9 +521,9 @@ def _get_text1_transform(self):
518521
def _get_text2_transform(self):
519522
return self.axes.get_yaxis_text2_transform(self._pad)
520523

521-
def apply_tickdir(self, tickdir):
524+
def _apply_tickdir(self, tickdir):
522525
# docstring inherited
523-
super().apply_tickdir(tickdir)
526+
super()._apply_tickdir(tickdir)
524527
self._tickmarkers = {
525528
'out': (mlines.TICKLEFT, mlines.TICKRIGHT),
526529
'in': (mlines.TICKRIGHT, mlines.TICKLEFT),

0 commit comments

Comments
 (0)
0