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

Skip to content

Commit 3035a0a

Browse files
committed
Fixes and cleans code related to pyplot xticks() and yticks() to allow setting only the labels
1 parent 56905d2 commit 3035a0a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/matplotlib/pyplot.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,15 +1428,16 @@ def xticks(ticks=None, labels=None, **kwargs):
14281428
"""
14291429
ax = gca()
14301430

1431-
if ticks is None and labels is None:
1431+
if ticks is None:
14321432
locs = ax.get_xticks()
1433-
labels = ax.get_xticklabels()
1434-
elif labels is None:
1433+
else:
14351434
locs = ax.set_xticks(ticks)
1435+
1436+
if labels is None:
14361437
labels = ax.get_xticklabels()
14371438
else:
1438-
locs = ax.set_xticks(ticks)
14391439
labels = ax.set_xticklabels(labels, **kwargs)
1440+
14401441
for l in labels:
14411442
l.update(kwargs)
14421443

@@ -1503,15 +1504,16 @@ def yticks(ticks=None, labels=None, **kwargs):
15031504
"""
15041505
ax = gca()
15051506

1506-
if ticks is None and labels is None:
1507+
if ticks is None:
15071508
locs = ax.get_yticks()
1508-
labels = ax.get_yticklabels()
1509-
elif labels is None:
1509+
else:
15101510
locs = ax.set_yticks(ticks)
1511+
1512+
if labels is None:
15111513
labels = ax.get_yticklabels()
15121514
else:
1513-
locs = ax.set_yticks(ticks)
15141515
labels = ax.set_yticklabels(labels, **kwargs)
1516+
15151517
for l in labels:
15161518
l.update(kwargs)
15171519

0 commit comments

Comments
 (0)