@@ -1632,24 +1632,60 @@ def yscale(*args, **kwargs):
1632
1632
1633
1633
def xticks (* args , ** kwargs ):
1634
1634
"""
1635
- Get or set the *x*-limits of the current tick locations and labels.
1635
+ Get or set the current tick locations and labels of the x-axis .
1636
1636
1637
- ::
1637
+ Call signatures::
1638
+
1639
+ locs, labels = xticks() # Get locations and labels
1640
+
1641
+ xticks(locs, [labels], **kwargs) # Set locations and labels
1642
+
1643
+ Parameters
1644
+ ----------
1645
+ locs : array_like
1646
+ A list of positions at which ticks should be placed.
1647
+
1648
+ labels : array_like, optional
1649
+ A list of explicit labels to place the the given *locs*. You can pass
1650
+ an empty list to disable xticks.
1651
+
1652
+ **kwargs
1653
+ :class:`.Text` properties can be used to control the appearence of
1654
+ the labels.
1655
+
1656
+ Returns
1657
+ -------
1658
+ locs
1659
+ An array of label locations.
1660
+ labels
1661
+ A list of `.Text` objects.
1662
+
1663
+ Notes
1664
+ -----
1665
+ This is just a convenient shortcut for calling `.get_xticks` and
1666
+ `.get_xticklabels` or `.set_xticks` and `.set_xticklabels` on the current
1667
+ axes.
1668
+
1669
+ Examples
1670
+ --------
1671
+ Get the current locations and labels:
1672
+
1673
+ >>> locs, labels = xticks()
1674
+
1675
+ Set label locations:
1676
+
1677
+ >>> xticks(np.arange(0, 1, step=0.2))
1678
+
1679
+ Set text labels:
1638
1680
1639
- # return locs, labels where locs is an array of tick locations and
1640
- # labels is an array of tick labels.
1641
- locs, labels = xticks()
1681
+ >>> xticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1642
1682
1643
- # set the locations of the xticks
1644
- xticks( arange(6) )
1645
1683
1646
- # set the locations and labels of the xticks
1647
- xticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
1684
+ >>> xticks(np.arange(12), calendar.month_name[1:13], rotation=20)
1648
1685
1649
- The keyword args, if any, are :class:`~matplotlib.text.Text`
1650
- properties. For example, to rotate long labels::
1686
+ Disable xticks:
1651
1687
1652
- xticks( arange(12), calendar.month_name[1:13], rotation=17 )
1688
+ >>> xticks([] )
1653
1689
"""
1654
1690
ax = gca ()
1655
1691
@@ -1672,24 +1708,60 @@ def xticks(*args, **kwargs):
1672
1708
1673
1709
def yticks (* args , ** kwargs ):
1674
1710
"""
1675
- Get or set the *y*-limits of the current tick locations and labels.
1711
+ Get or set the current tick locations and labels of the y-axis .
1676
1712
1677
- ::
1713
+ Call signatures::
1714
+
1715
+ locs, labels = yticks() # Get locations and labels
1716
+
1717
+ yticks(locs, [labels], **kwargs) # Set locations and labels
1718
+
1719
+ Parameters
1720
+ ----------
1721
+ locs : array_like
1722
+ A list of positions at which ticks should be placed.
1723
+
1724
+ labels : array_like, optional
1725
+ A list of explicit labels to place the the given *locs*. You can pass
1726
+ an empty list to disable yticks.
1727
+
1728
+ **kwargs
1729
+ :class:`.Text` properties can be used to control the appearence of
1730
+ the labels.
1731
+
1732
+ Returns
1733
+ -------
1734
+ locs
1735
+ An array of label locations.
1736
+ labels
1737
+ A list of `.Text` objects.
1738
+
1739
+ Notes
1740
+ -----
1741
+ This is just a convenient shortcut for calling `.get_yticks` and
1742
+ `.get_yticklabels` or `.set_yticks` and `.set_yticklabels` on the current
1743
+ axes.
1744
+
1745
+ Examples
1746
+ --------
1747
+ Get the current locations and labels:
1748
+
1749
+ >>> locs, labels = yticks()
1750
+
1751
+ Set label locations:
1752
+
1753
+ >>> yticks(np.arange(0, 1, step=0.2))
1754
+
1755
+ Set text labels:
1678
1756
1679
- # return locs, labels where locs is an array of tick locations and
1680
- # labels is an array of tick labels.
1681
- locs, labels = yticks()
1757
+ >>> yticks(np.arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue'))
1682
1758
1683
- # set the locations of the yticks
1684
- yticks( arange(6) )
1685
1759
1686
- # set the locations and labels of the yticks
1687
- yticks( arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue') )
1760
+ >>> yticks(np.arange(12), calendar.month_name[1:13], rotation=45)
1688
1761
1689
- The keyword args, if any, are :class:`~matplotlib.text.Text`
1690
- properties. For example, to rotate long labels::
1762
+ Disable yticks:
1691
1763
1692
- yticks( arange(12), calendar.month_name[1:13], rotation=45 )
1764
+ >>> yticks([] )
1693
1765
"""
1694
1766
ax = gca ()
1695
1767
0 commit comments