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

Skip to content

Commit f53cc28

Browse files
authored
Merge pull request #15789 from anntzer/ticks
Cleanup xticks/yticks docstrings.
2 parents 6990a85 + 3c4e8f6 commit f53cc28

File tree

1 file changed

+26
-62
lines changed

1 file changed

+26
-62
lines changed

lib/matplotlib/pyplot.py

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,29 +1365,24 @@ def xticks(ticks=None, labels=None, **kwargs):
13651365
"""
13661366
Get or set the current tick locations and labels of the x-axis.
13671367
1368-
Call signatures::
1369-
1370-
locs, labels = xticks() # Get locations and labels
1371-
xticks(ticks, [labels], **kwargs) # Set locations and labels
1368+
Pass no arguments to return the current values without modifying them.
13721369
13731370
Parameters
13741371
----------
1375-
ticks : array-like
1376-
A list of positions at which ticks should be placed. You can pass an
1377-
empty list to disable xticks.
1378-
1372+
ticks : array-like, optional
1373+
The list of xtick locations. Passing an empty list removes all xticks.
13791374
labels : array-like, optional
1380-
A list of explicit labels to place at the given *locs*.
1381-
1375+
The labels to place at the given *ticks* locations. This argument can
1376+
only be passed if *ticks* is passed as well.
13821377
**kwargs
13831378
`.Text` properties can be used to control the appearance of the labels.
13841379
13851380
Returns
13861381
-------
13871382
locs
1388-
An array of label locations.
1383+
The list of xtick locations.
13891384
labels
1390-
A list of `.Text` objects.
1385+
The list of xlabel `.Text` objects.
13911386
13921387
Notes
13931388
-----
@@ -1399,25 +1394,12 @@ def xticks(ticks=None, labels=None, **kwargs):
13991394
14001395
Examples
14011396
--------
1402-
Get the current locations and labels:
1403-
1404-
>>> locs, labels = xticks()
1405-
1406-
Set label locations:
1407-
1408-
>>> xticks(np.arange(0, 1, step=0.2))
1409-
1410-
Set text labels:
1411-
1412-
>>> xticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1413-
1414-
Set text labels and properties:
1415-
1416-
>>> xticks(np.arange(12), calendar.month_name[1:13], rotation=20)
1417-
1418-
Disable xticks:
1419-
1420-
>>> xticks([])
1397+
>>> locs, labels = xticks() # Get the current locations and labels.
1398+
>>> xticks(np.arange(0, 1, step=0.2)) # Set label locations.
1399+
>>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
1400+
>>> xticks([0, 1, 2], ['January', 'February', 'March'],
1401+
... rotation=20) # Set text labels and properties.
1402+
>>> xticks([]) # Disable xticks.
14211403
"""
14221404
ax = gca()
14231405

@@ -1440,29 +1422,24 @@ def yticks(ticks=None, labels=None, **kwargs):
14401422
"""
14411423
Get or set the current tick locations and labels of the y-axis.
14421424
1443-
Call signatures::
1444-
1445-
locs, labels = yticks() # Get locations and labels
1446-
yticks(ticks, [labels], **kwargs) # Set locations and labels
1425+
Pass no arguments to return the current values without modifying them.
14471426
14481427
Parameters
14491428
----------
1450-
ticks : array-like
1451-
A list of positions at which ticks should be placed. You can pass an
1452-
empty list to disable yticks.
1453-
1429+
ticks : array-like, optional
1430+
The list of xtick locations. Passing an empty list removes all xticks.
14541431
labels : array-like, optional
1455-
A list of explicit labels to place at the given *locs*.
1456-
1432+
The labels to place at the given *ticks* locations. This argument can
1433+
only be passed if *ticks* is passed as well.
14571434
**kwargs
14581435
`.Text` properties can be used to control the appearance of the labels.
14591436
14601437
Returns
14611438
-------
14621439
locs
1463-
An array of label locations.
1440+
The list of ytick locations.
14641441
labels
1465-
A list of `.Text` objects.
1442+
The list of ylabel `.Text` objects.
14661443
14671444
Notes
14681445
-----
@@ -1474,25 +1451,12 @@ def yticks(ticks=None, labels=None, **kwargs):
14741451
14751452
Examples
14761453
--------
1477-
Get the current locations and labels:
1478-
1479-
>>> locs, labels = yticks()
1480-
1481-
Set label locations:
1482-
1483-
>>> yticks(np.arange(0, 1, step=0.2))
1484-
1485-
Set text labels:
1486-
1487-
>>> yticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1488-
1489-
Set text labels and properties:
1490-
1491-
>>> yticks(np.arange(12), calendar.month_name[1:13], rotation=45)
1492-
1493-
Disable yticks:
1494-
1495-
>>> yticks([])
1454+
>>> locs, labels = yticks() # Get the current locations and labels.
1455+
>>> yticks(np.arange(0, 1, step=0.2)) # Set label locations.
1456+
>>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
1457+
>>> yticks([0, 1, 2], ['January', 'February', 'March'],
1458+
... rotation=45) # Set text labels and properties.
1459+
>>> yticks([]) # Disable yticks.
14961460
"""
14971461
ax = gca()
14981462

0 commit comments

Comments
 (0)