8000 Merge pull request #15867 from meeseeksmachine/auto-backport-of-pr-15… · matplotlib/matplotlib@d0baa6b · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit d0baa6b

Browse files
authored
Merge pull request #15867 from meeseeksmachine/auto-backport-of-pr-15789-on-v3.2.x
Backport PR #15789 on branch v3.2.x (Cleanup xticks/yticks docstrings.)
2 parents 82ad5b6 + 0f00395 commit d0baa6b

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
@@ -1431,29 +1431,24 @@ def xticks(ticks=None, labels=None, **kwargs):
14311431
"""
14321432
Get or set the current tick locations and labels of the x-axis.
14331433
1434-
Call signatures::
1435-
1436-
locs, labels = xticks() # Get locations and labels
1437-
xticks(ticks, [labels], **kwargs) # Set locations and labels
1434+
Pass no arguments to return the current values without modifying them.
14381435
14391436
Parameters
14401437
----------
1441-
ticks : array-like
1442-
A list of positions at which ticks should be placed. You can pass an
1443-
empty list to disable xticks.
1444-
1438+
ticks : array-like, optional
1439+
The list of xtick locations. Passing an empty list removes all xticks.
14451440
labels : array-like, optional
1446-
A list of explicit labels to place at the given *locs*.
1447-
1441+
The labels to place at the given *ticks* locations. This argument can
1442+
only be passed if *ticks* is passed as well.
14481443
**kwargs
14491444
`.Text` properties can be used to control the appearance of the labels.
14501445
14511446
Returns
14521447
-------
14531448
locs
1454-
An array of label locations.
1449+
The list of xtick locations.
14551450
labels
1456-
A list of `.Text` objects.
1451+
The list of xlabel `.Text` objects.
14571452
14581453
Notes
14591454
-----
@@ -1465,25 +1460,12 @@ def xticks(ticks=None, labels=None, **kwargs):
14651460
14661461
Examples
14671462
--------
1468-
Get the current locations and labels:
1469-
1470-
>>> locs, labels = xticks()
1471-
1472-
Set label locations:
1473-
1474-
>>> xticks(np.arange(0, 1, step=0.2))
1475-
1476-
Set text labels:
1477-
1478-
>>> xticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1479-
1480-
Set text labels and properties:
1481-
1482-
>>> xticks(np.arange(12), calendar.month_name[1:13], rotation=20)
1483-
1484-
Disable xticks:
1485-
1486-
>>> xticks([])
1463+
>>> locs, labels = xticks() # Get the current locations and labels.
1464+
>>> xticks(np.arange(0, 1, step=0.2)) # Set label locations.
1465+
>>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
1466+
>>> xticks([0, 1, 2], ['January', 'February', 'March'],
1467+
... rotation=20) # Set text labels and properties.
1468+
>>> xticks([]) # Disable xticks.
14871469
"""
14881470
ax = gca()
14891471

@@ -1506,29 +1488,24 @@ def yticks(ticks=None, labels=None, **kwargs):
15061488
"""
15071489
Get or set the current tick locations and labels of the y-axis.
15081490
1509-
Call signatures::
1510-
1511-
locs, labels = yticks() # Get locations and labels
1512-
yticks(ticks, [labels], **kwargs) # Set locations and labels
1491+
Pass no arguments to return the current values without modifying them.
15131492
15141493
Parameters
15151494
----------
1516-
ticks : array-like
1517-
A list of positions at which ticks should be placed. You can pass an
1518-
empty list to disable yticks.
1519-
1495+
ticks : array-like, optional
1496+
The list of xtick locations. Passing an empty list removes all xticks.
15201497
labels : array-like, optional
1521-
A list of explicit labels to place at the given *locs*.
1522-
1498+
The labels to place at the given *ticks* locations. This argument can
1499+
only be passed if *ticks* is passed as well.
15231500
**kwargs
15241501
`.Text` properties can be used to control the appearance of the labels.
15251502
15261503
Returns
15271504
-------
15281505
locs
1529-
An array of label locations.
1506+
The list of ytick locations.
15301507
labels
1531-
A list of `.Text` objects.
1508+
The list of ylabel `.Text` objects.
15321509
15331510
Notes
15341511
-----
@@ -1540,25 +1517,12 @@ def yticks(ticks=None, labels=None, **kwargs):
15401517
15411518
Examples
15421519
--------
1543-
Get the current locations and labels:
1544-
1545-
>>> locs, labels = yticks()
1546-
1547-
Set label locations:
1548-
1549-
>>> yticks(np.arange(0, 1, step=0.2))
1550-
1551-
Set text labels:
1552-
1553-
>>> yticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1554-
1555-
Set text labels and properties:
1556-
1557-
>>> yticks(np.arange(12), calendar.month_name[1:13], rotation=45)
1558-
1559-
Disable yticks:
1560-
1561-
>>> yticks([])
1520+
>>> locs, labels = yticks() # Get the current locations and labels.
1521+
>>> yticks(np.arange(0, 1, step=0.2)) # Set label locations.
1522+
>>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
1523+
>>> yticks([0, 1, 2], ['January', 'February', 'March'],
1524+
... rotation=45) # Set text labels and properties.
1525+
>>> yticks([]) # Disable yticks.
15621526
"""
15631527
ax = gca()
15641528

0 commit comments

Comments
 (0)
0