Skip to content

Commit 274fbdc

Browse files
committed
xticks() and yticks() now raise TypeError instead of AttributeError when parameter ticks is missing
1 parent 9741a2f commit 274fbdc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/pyplot.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,8 @@ def xticks(ticks=None, labels=None, **kwargs):
13971397
if ticks is None:
13981398
locs = ax.get_xticks()
13991399
if labels is not None:
1400-
raise AttributeError("Labels can't be set without setting ticks")
1400+
raise TypeError("xticks(): Parameter 'labels' can't be set without "
1401+
"setting 'ticks'")
14011402
else:
14021403
locs = ax.set_xticks(ticks)
14031404

@@ -1456,7 +1457,8 @@ def yticks(ticks=None, labels=None, **kwargs):
14561457
if ticks is None:
14571458
locs = ax.get_yticks()
14581459
if labels is not None:
1459-
raise AttributeError("Labels can't be set without setting ticks")
1460+
raise TypeError("yticks(): Parameter 'labels' can't be set without "
1461+
"setting 'ticks'")
14601462
else:
14611463
locs = ax.set_yticks(ticks)
14621464

0 commit comments

Comments
 (0)