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

Skip to content

Commit 5c16159

Browse files
committed
Convert docstring for set_xlim(), per issue #7205
Convert set_xlim() docstring to numpydoc format.
1 parent a30f451 commit 5c16159

File tree

1 file changed

+39
-30
lines changed

1 file changed

+39
-30
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,49 +2788,58 @@ def get_xlim(self):
27882788
return tuple(self.viewLim.intervalx)
27892789

27902790
def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
2791-
"""Set the data limits for the xaxis
2791+
"""Set the data limits for the x-axis
27922792
2793-
Call signature::
2794-
2795-
set_xlim(self, *args, **kwargs):
2793+
Parameters
2794+
----------
2795+
left : scalar, optional
2796+
The left xlim (default: None, which leaves the left limit
2797+
unchanged). The previous name `xmin` may be used instead.
27962798
2797-
Set the data limits for the xaxis
2799+
right : scalar, optional
2800+
The right xlim (default: None, which leaves the right limit
2801+
unchanged). The previous name `xmax` may be used instead.
27982802
2799-
Examples::
2800-
2801-
set_xlim((left, right))
2802-
set_xlim(left, right)
2803-
set_xlim(left=1) # right unchanged
2804-
set_xlim(right=1) # left unchanged
2803+
emit : bool, optional
2804+
Whether to notify observers of limit change (default: True).
28052805
2806-
Keyword arguments:
2806+
auto : {True, False, None}, optional
2807+
Whether to turn on autoscaling of the x-axis. True turns on,
2808+
False turns off (default action), None leaves unchanged.
28072809
2808-
*left*: scalar
2809-
The left xlim; *xmin*, the previous name, may still be used
2810+
xlimits : tuple, optional
2811+
The left and right xlims may be passed as the tuple
2812+
(`left`, `right`) as the first positional argument (or as
2813+
the `left` keyword argument).
28102814
2811-
*right*: scalar
2812-
The right xlim; *xmax*, the previous name, may still be used
2815+
Returns
2816+
-------
2817+
xlimits : tuple
2818+
Returns the current x-axis limits, reflecting any changes
2819+
made by this call, as (`left`, `right`).
28132820
2814-
*emit*: [ *True* | *False* ]
2815-
Notify observers of limit change
2821+
Notes
2822+
-----
2823+
The `left` value may be greater than the `right` value, in which
2824+
case the x-axis values will decrease from left to right.
28162825
2817-
*auto*: [ *True* | *False* | *None* ]
2818-
Turn *x* autoscaling on (*True*), off (*False*; default),
2819-
or leave unchanged (*None*)
2826+
Examples
2827+
--------
2828+
>>> set_xlim(left, right)
2829+
>>> set_xlim((left, right))
2830+
>>> left, right = set_xlim(left, right)
28202831
2821-
Note, the *left* (formerly *xmin*) value may be greater than
2822-
the *right* (formerly *xmax*).
2823-
For example, suppose *x* is years before present.
2824-
Then one might use::
2832+
One limit may be left unchanged.
28252833
2826-
set_xlim(5000, 0)
2834+
>>> set_xlim(right=right_lim)
28272835
2828-
so 5000 years ago is on the left of the plot and the
2829-
present is on the right.
2836+
Limits may be passed in reverse order. For example, suppose `x`
2837+
represents the number of years before present. The x-axis limits
2838+
might be set like the following so 5000 years ago is on the left
2839+
of the plot and the present is on the right.
28302840
2831-
Returns the current xlimits as a length 2 tuple
2841+
>>> set_xlim(5000, 0)
28322842
2833-
ACCEPTS: length 2 sequence of floats
28342843
"""
28352844
if 'xmin' in kw:
28362845
left = kw.pop('xmin')

0 commit comments

Comments
 (0)