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

Skip to content

Commit 2748d57

Browse files
committed
Fix docstrings affected by move to dynamic pyplot.
1 parent 24e59a6 commit 2748d57

File tree

4 files changed

+76
-75
lines changed

4 files changed

+76
-75
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def get_ylabel(self):
239239

240240
def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs):
241241
"""
242-
Set the label for the yaxis
242+
Set the label for the yaxis.
243243
244244
Parameters
245245
----------

lib/matplotlib/axes/_base.py

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,45 +1619,40 @@ def apply_aspect(self, position=None):
16191619
self.set_xbound((x0, x1))
16201620

16211621
def axis(self, *v, **kwargs):
1622-
"""Set axis properties.
1622+
"""Convenience method to get or set axis properties.
16231623
16241624
Valid signatures::
16251625
1626-
xmin, xmax, ymin, ymax = axis()
1627-
xmin, xmax, ymin, ymax = axis(list_arg)
1628-
xmin, xmax, ymin, ymax = axis(string_arg)
1629-
xmin, xmax, ymin, ymax = axis(**kwargs)
1626+
xmin, xmax, ymin, ymax = axis(*, emit=True)
1627+
xmin, xmax, ymin, ymax = axis(_string_arg_, *, emit=True)
1628+
xmin, xmax, ymin, ymax = axis([xmin, ymin, xmax, ymax], *, emit=True)
16301629
16311630
Parameters
16321631
----------
1633-
v : list of float or {'on', 'off', 'equal', 'tight', 'scaled',\
1634-
'normal', 'auto', 'image', 'square'}
1635-
Optional positional argument
1636-
1637-
Axis data limits set from a list; or a command relating to axes:
1638-
1639-
========== ================================================
1640-
Value Description
1641-
========== ================================================
1642-
'on' Toggle axis lines and labels on
1643-
'off' Toggle axis lines and labels off
1644-
'equal' Equal scaling by changing limits
1645-
'scaled' Equal scaling by changing box dimensions
1646-
'tight' Limits set such that all data is shown
1647-
'auto' Automatic scaling, fill rectangle with data
1648-
'normal' Same as 'auto'; deprecated
1649-
'image' 'scaled' with axis limits equal to data limits
1650-
'square' Square plot; similar to 'scaled', but initially\
1651-
forcing xmax-xmin = ymax-ymin
1652-
========== ================================================
1653-
1654-
emit : bool, optional
1655-
Passed to set_{x,y}lim functions, if observers
1656-
are notified of axis limit change
1632+
_string_arg_ : str, optional
1633+
1634+
The following values are allowed:
1635+
1636+
========== =======================================================
1637+
Value Description
1638+
========== =======================================================
1639+
'on' Toggle axis lines and labels on
1640+
'off' Toggle axis lines and labels off
1641+
'equal' Equal scaling by changing limits
1642+
'scaled' Equal scaling by changing box dimensions
1643+
'tight' Limits set such that all data is shown
1644+
'auto' Automatic scaling, fill rectangle with data
1645+
'image' 'scaled' with axis limits equal to data limits
1646+
'square' Square plot; similar to 'scaled', but initially forcing
1647+
``xmax-xmin = ymax-ymin``
1648+
========== =======================================================
16571649
16581650
xmin, ymin, xmax, ymax : float, optional
16591651
The axis limits to be set
16601652
1653+
emit : bool, optional
1654+
Whether observers are notified of axes limit changes.
1655+
16611656
Returns
16621657
-------
16631658
xmin, xmax, ymin, ymax : float
@@ -1678,17 +1673,15 @@ def axis(self, *v, **kwargs):
16781673
self.set_axis_on()
16791674
elif s == 'off':
16801675
self.set_axis_off()
1681-
elif s in ('equal', 'tight', 'scaled', 'normal',
1682-
'auto', 'image', 'square'):
1676+
elif s in ['equal', 'tight', 'scaled', 'auto', 'image', 'square']:
16831677
self.set_autoscale_on(True)
16841678
self.set_aspect('auto')
16851679
self.autoscale_view(tight=False)
1686-
# self.apply_aspect()
16871680
if s == 'equal':
16881681
self.set_aspect('equal', adjustable='datalim')
16891682
elif s == 'scaled':
16901683
self.set_aspect('equal', adjustable='box', anchor='C')
1691-
self.set_autoscale_on(False) # Req. by Mark Bakker
1684+
self.set_autoscale_on(False)
16921685
elif s == 'tight':
16931686
self.autoscale_view(tight=True)
16941687
self.set_autoscale_on(False)
@@ -3126,14 +3119,14 @@ def set_xscale(self, value, **kwargs):
31263119
"""
31273120
Set the x-axis scale.
31283121
3129-
..
3130-
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3131-
31323122
Parameters
31333123
----------
31343124
value : {"linear", "log", "symlog", "logit"}
31353125
scaling strategy to apply
31363126
3127+
..
3128+
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3129+
31373130
Notes
31383131
-----
31393132
Different kwargs are accepted, depending on the scale. See
@@ -3451,14 +3444,14 @@ def set_yscale(self, value, **kwargs):
34513444
"""
34523445
Set the y-axis scale.
34533446
3454-
..
3455-
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3456-
34573447
Parameters
34583448
----------
34593449
value : {"linear", "log", "symlog", "logit"}
34603450
scaling strategy to apply
34613451
3452+
..
3453+
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3454+
34623455
Notes
34633456
-----
34643457
Different kwargs are accepted, depending on the scale. See

lib/matplotlib/figure.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ def _set_artist_props(self, a):
16281628
@docstring.dedent_interpd
16291629
def gca(self, **kwargs):
16301630
"""
1631-
Get the current axes, creating one if necessary
1631+
Get the current axes, creating one if necessary.
16321632
16331633
The following kwargs are supported for ensuring the returned axes
16341634
adheres to the given projection etc., and for axes creation if
@@ -1674,17 +1674,14 @@ def gca(self, **kwargs):
16741674
return self.add_subplot(1, 1, 1, **kwargs)
16751675

16761676
def sca(self, a):
1677-
'Set the current axes to be a and return a'
1677+
"""Set the current axes to be a and return a."""
16781678
self._axstack.bubble(a)
16791679
for func in self._axobservers:
16801680
func(self)
16811681
return a
16821682

16831683
def _gci(self):
1684-
"""
1685-
helper for :func:`~matplotlib.pyplot.gci`;
1686-
do not use elsewhere.
1687-
"""
1684+
"""Get the current colorable artist."""
16881685
# Look first for an image in the current Axes:
16891686
cax = self._axstack.current_key_axes()[1]
16901687
if cax is None:
@@ -1920,18 +1917,30 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
19201917
self.stale = True
19211918
return cb
19221919

1923-
def subplots_adjust(self, *args, **kwargs):
1920+
def subplots_adjust(self, left=None, bottom=None, right=None, top=None,
1921+
wspace=None, hspace=None):
19241922
"""
1925-
Call signature::
1923+
Update the figure's `SubplotParams` and the subplot locations.
19261924
1927-
subplots_adjust(left=None, bottom=None, right=None, top=None,
1928-
wspace=None, hspace=None)
1925+
All parameters default to their respective rcParams.
19291926
1930-
Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
1931-
*None*) and update the subplot locations
1932-
1933-
"""
1934-
self.subplotpars.update(*args, **kwargs)
1927+
Parameters
1928+
----------
1929+
left : float
1930+
Left edge of the subplots of the figure.
1931+
right : float
1932+
Right edge of the subplots of the figure.
1933+
bottom : float
1934+
Bottom edge of the subplots of the figure.
1935+
top : float
1936+
Top edge of the subplots of the figure.
1937+
wspace : float
1938+
Amount of width reserved as blank space between subplots.
1939+
hspace : float
1940+
Amount of height reserved as blank space between subplots.
1941+
"""
1942+
self.subplotpars.update(left=left, bottom=bottom, right=right, top=top,
1943+
wspace=wspace, hspace=hspace)
19351944
for ax in self.axes:
19361945
if not isinstance(ax, SubplotBase):
19371946
# Check if sharing a subplots axis
@@ -2052,19 +2061,16 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
20522061
20532062
Parameters
20542063
----------
2055-
2056-
pad : float
2057-
padding between the figure edge and the edges of subplots,
2058-
as a fraction of the font-size.
2059-
2064+
pad : float, optional
2065+
Padding between the figure edge and the edges of subplots, as a
2066+
fraction of the font-size.
20602067
h_pad, w_pad : float, optional
2061-
padding (height/width) between edges of adjacent subplots.
2062-
Defaults to `pad_inches`.
2063-
2064-
rect : tuple (left, bottom, right, top), optional
2065-
a rectangle (left, bottom, right, top) in the normalized
2066-
figure coordinate that the whole subplots area (including
2067-
labels) will fit into. Default is (0, 0, 1, 1).
2068+
Padding (height/width) between edges of adjacent subplots.
2069+
Defaults to *pad_inches*.
2070+
rect : Tuple[float, float, float, float], optional
2071+
(left, bottom, right, top) rectangle in normalized figure
2072+
coordinates that the whole subplots area (including labels) will
2073+
fit into. Defaults to using the entire figure.
20682074
"""
20692075

20702076
from .tight_layout import (

lib/matplotlib/pyplot.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def _backend_selection():
114114

115115
def install_repl_displayhook():
116116
"""
117-
Install a repl display hook so that any stale figure are automatically
118-
redrawn when control is returned to the repl.
117+
Install a REPL display hook so that any stale figure are automatically
118+
redrawn when control is returned to the REPL.
119119
120-
This works with IPython terminals and kernels,
121-
as well as vanilla python shells.
120+
This works with IPython terminals and kernels, as well as vanilla Python
121+
shells.
122122
"""
123123
global _IP_REGISTERED
124124
global _INSTALL_FIG_OBSERVER
@@ -168,7 +168,7 @@ def post_execute():
168168

169169
def uninstall_repl_displayhook():
170170
"""
171-
Uninstalls the matplotlib display hook.
171+
Uninstall the matplotlib display hook.
172172
173173
.. warning
174174
@@ -835,7 +835,7 @@ def subplot(*args, **kwargs):
835835
def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
836836
subplot_kw=None, gridspec_kw=None, **fig_kw):
837837
"""
838-
Create a figure and a set of subplots
838+
Create a figure and a set of subplots.
839839
840840
This utility wrapper makes it convenient to create common layouts of
841841
subplots, including the enclosing figure object, in a single call.
@@ -1664,13 +1664,15 @@ def pad(s, l):
16641664
max_name = 0
16651665
max_summary = 0
16661666
for name in commands:
1667-
doc = globals()[name].__doc__
1667+
func = globals()[name]
1668+
doc = inspect.getdoc(func)
16681669
summary = ''
16691670
if doc is not None:
16701671
match = first_sentence.match(doc)
16711672
if match is not None:
16721673
summary = match.group(0).strip().replace('\n', ' ')
1673-
name = '`%s`' % name
1674+
name = ("`{0.__name__}`" if func.__module__ == __name__
1675+
else "`~{0.__module__}.{0.__name__}`").format(func)
16741676
rows.append([name, summary])
16751677
max_name = max(max_name, len(name))
16761678
max_summary = max(max_summary, len(summary))

0 commit comments

Comments
 (0)