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 6be9c9f

Browse filesBrowse files
committed
Use named args for xticks, yticks in pyplot
1 parent 9c7e0de commit 6be9c9f
Copy full SHA for 6be9c9f

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+16
-20
lines changed

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+16-20Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,19 +1365,19 @@ def ylim(*args, **kwargs):
13651365
return ret
13661366

13671367

1368-
def xticks(*args, **kwargs):
1368+
def xticks(ticks=None, labels=None, **kwargs):
13691369
"""
13701370
Get or set the current tick locations and labels of the x-axis.
13711371
13721372
Call signatures::
13731373
13741374
locs, labels = xticks() # Get locations and labels
13751375
1376-
xticks(locs, [labels], **kwargs) # Set locations and labels
1376+
xticks(ticks, [labels], **kwargs) # Set locations and labels
13771377
13781378
Parameters
13791379
----------
1380-
locs : array_like
1380+
ticks : array_like
13811381
A list of positions at which ticks should be placed. You can pass an
13821382
empty list to disable xticks.
13831383
@@ -1427,36 +1427,34 @@ def xticks(*args, **kwargs):
14271427
"""
14281428
ax = gca()
14291429

1430-
if len(args) == 0:
1430+
if ticks is None and labels is None:
14311431
locs = ax.get_xticks()
14321432
labels = ax.get_xticklabels()
1433-
elif len(args) == 1:
1434-
locs = ax.set_xticks(args[0])
1433+
elif labels is None:
1434+
locs = ax.set_xticks(ticks)
14351435
labels = ax.get_xticklabels()
1436-
elif len(args) == 2:
1437-
locs = ax.set_xticks(args[0])
1438-
labels = ax.set_xticklabels(args[1], **kwargs)
14391436
else:
1440-
raise TypeError('Illegal number of arguments to xticks')
1437+
locs = ax.set_xticks(ticks)
1438+
labels = ax.set_xticklabels(labels, **kwargs)
14411439
for l in labels:
14421440
l.update(kwargs)
14431441

14441442
return locs, silent_list('Text xticklabel', labels)
14451443

14461444

1447-
def yticks(*args, **kwargs):
1445+
def yticks(ticks=None, labels=None, **kwargs):
14481446
"""
14491447
Get or set the current tick locations and labels of the y-axis.
14501448
14511449
Call signatures::
14521450
14531451
locs, labels = yticks() # Get locations and labels
14541452
1455-
yticks(locs, [labels], **kwargs) # Set locations and labels
1453+
yticks(ticks, [labels], **kwargs) # Set locations and labels
14561454
14571455
Parameters
14581456
----------
1459-
locs : array_like
1457+
ticks : array_like
14601458
A list of positions at which ticks should be placed. You can pass an
14611459
empty list to disable yticks.
14621460
@@ -1506,17 +1504,15 @@ def yticks(*args, **kwargs):
15061504
"""
15071505
ax = gca()
15081506

1509-
if len(args) == 0:
1507+
if ticks is None and labels is None:
15101508
locs = ax.get_yticks()
15111509
labels = ax.get_yticklabels()
1512-
elif len(args) == 1:
1513-
locs = ax.set_yticks(args[0])
1510+
elif labels is None:
1511+
locs = ax.set_yticks(ticks)
15141512
labels = ax.get_yticklabels()
1515-
elif len(args) == 2:
1516-
locs = ax.set_yticks(args[0])
1517-
labels = ax.set_yticklabels(args[1], **kwargs)
15181513
else:
1519-
raise TypeError('Illegal number of arguments to yticks')
1514+
locs = ax.set_yticks(ticks)
1515+
labels = ax.set_yticklabels(labels, **kwargs)
15201516
for l in labels:
15211517
l.update(kwargs)
15221518

0 commit comments

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