Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4873c3c

Browse filesBrowse files
authored
Merge pull request #13518 from meeseeksmachine/auto-backport-of-pr-12839-on-v3.1.x
Backport PR #12839 on branch v3.1.x (BUG: Prevent Tick params calls from overwriting visibility without being told to)
2 parents 820ea41 + 8299d68 commit 4873c3c
Copy full SHA for 4873c3c

File tree

Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,9 @@ def set_tick_params(self, which='major', reset=False, **kw):
859859
if which == 'minor' or which == 'both':
860860
dicts.append(self._minor_tick_kw)
861861
kwtrans = self._translate_tick_kw(kw)
862+
863+
# this stashes the parameter changes so any new ticks will
864+
# automatically get them
862865
for d in dicts:
863866
if reset:
864867
d.clear()
@@ -867,14 +870,18 @@ def set_tick_params(self, which='major', reset=False, **kw):
867870
if reset:
868871
self.reset_ticks()
869872
else:
873+
# apply the new kwargs to the existing ticks
870874
if which == 'major' or which == 'both':
871875
for tick in self.majorTicks:
872-
tick._apply_params(**self._major_tick_kw)
876+
tick._apply_params(**kwtrans)
873877
if which == 'minor' or which == 'both':
874878
for tick in self.minorTicks:
875-
tick._apply_params(**self._minor_tick_kw)
879+
tick._apply_params(**kwtrans)
880+
# special-case label color to also apply to the offset
881+
# text
876882
if 'labelcolor' in kwtrans:
877883
self.offsetText.set_color(kwtrans['labelcolor'])
884+
878885
self.stale = True
879886

880887
@staticmethod
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,6 +4922,17 @@ def test_set_get_ticklabels():
49224922
ax[1].set_yticklabels(ax[0].get_yticklabels())
49234923

49244924

4925+
@image_comparison(
4926+
baseline_images=['retain_tick_visibility'],
4927+
extensions=['png'],
4928+
)
4929+
def test_retain_tick_visibility():
4930+
fig, ax = plt.subplots()
4931+
plt.plot([0, 1, 2], [0, -1, 4])
4932+
plt.setp(ax.get_yticklabels(), visible=False)
4933+
ax.tick_params(axis="y", which="both", length=0)
4934+
4935+
49254936
def test_tick_label_update():
49264937
# test issue 9397
49274938

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.