Skip to content

Commit 683d4c9

Browse files
committed
Simplify update logic
1 parent ec47e76 commit 683d4c9

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lib/matplotlib/axis.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -888,33 +888,29 @@ def set_tick_params(self, which='major', reset=False, **kw):
888888
For documentation of keyword arguments, see
889889
:meth:`matplotlib.axes.Axes.tick_params`.
890890
"""
891-
dicts = []
892891
cbook._check_in_list(['major', 'minor', 'both'], which=which)
893-
if which in ['major', 'both']:
894-
dicts.append(self._major_tick_kw)
895-
if which in ['minor', 'both']:
896-
dicts.append(self._minor_tick_kw)
897892
kwtrans = self._translate_tick_kw(kw)
898893

899-
# this stashes the parameter changes so any new ticks will
900-
# automatically get them
901-
for d in dicts:
902-
if reset:
903-
d.clear()
904-
d.update(kwtrans)
905-
894+
# the kwargs are stored in self._major/minor_tick_kw so that any
895+
# future new ticks will automatically get them
906896
if reset:
897+
if which in ['major', 'both']:
898+
self._major_tick_kw.clear()
899+
self._major_tick_kw.update(kwtrans)
900+
if which in ['minor', 'both']:
901+
self._minor_tick_kw.clear()
902+
self._minor_tick_kw.update(kwtrans)
907903
self.reset_ticks()
908904
else:
909-
# apply the new kwargs to the existing ticks
910905
if which in ['major', 'both']:
906+
self._major_tick_kw.update(kwtrans)
911907
for tick in self.majorTicks:
912908
tick._apply_params(**kwtrans)
913909
if which in ['minor', 'both']:
910+
self._minor_tick_kw.update(kwtrans)
914911
for tick in self.minorTicks:
915912
tick._apply_params(**kwtrans)
916-
# special-case label color to also apply to the offset
917-
# text
913+
# special-case label color to also apply to the offset text
918914
if 'labelcolor' in kwtrans:
919915
self.offsetText.set_color(kwtrans['labelcolor'])
920916

0 commit comments

Comments
 (0)