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

Skip to content

Commit c90ba52

Browse files
committed
Fix docstrings affected by move to dynamic pyplot.
1 parent c95c663 commit c90ba52

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
@@ -1606,45 +1606,40 @@ def apply_aspect(self, position=None):
16061606
self.set_xbound((x0, x1))
16071607

16081608
def axis(self, *v, **kwargs):
1609-
"""Set axis properties.
1609+
"""Convenience method to get or set axis properties.
16101610
16111611
Valid signatures::
16121612
1613-
xmin, xmax, ymin, ymax = axis()
1614-
xmin, xmax, ymin, ymax = axis(list_arg)
1615-
xmin, xmax, ymin, ymax = axis(string_arg)
1616-
xmin, xmax, ymin, ymax = axis(**kwargs)
1613+
xmin, xmax, ymin, ymax = axis(*, emit=True)
1614+
xmin, xmax, ymin, ymax = axis(_string_arg_, *, emit=True)
1615+
xmin, xmax, ymin, ymax = axis([xmin, ymin, xmax, ymax], *, emit=True)
16171616
16181617
Parameters
16191618
----------
1620-
v : list of float or {'on', 'off', 'equal', 'tight', 'scaled',\
1621-
'normal', 'auto', 'image', 'square'}
1622-
Optional positional argument
1623-
1624-
Axis data limits set from a list; or a command relating to axes:
1625-
1626-
========== ================================================
1627-
Value Description
1628-
========== ================================================
1629-
'on' Toggle axis lines and labels on
1630-
'off' Toggle axis lines and labels off
1631-
'equal' Equal scaling by changing limits
1632-
'scaled' Equal scaling by changing box dimensions
1633-
'tight' Limits set such that all data is shown
1634-
'auto' Automatic scaling, fill rectangle with data
1635-
'normal' Same as 'auto'; deprecated
1636-
'image' 'scaled' with axis limits equal to data limits
1637-
'square' Square plot; similar to 'scaled', but initially\
1638-
forcing xmax-xmin = ymax-ymin
1639-
========== ================================================
1640-
1641-
emit : bool, optional
1642-
Passed to set_{x,y}lim functions, if observers
1643-
are notified of axis limit change
1619+
_string_arg_ : str, optional
1620+
1621+
The following values are allowed:
1622+
1623+
========== =======================================================
1624+
Value Description
1625+
========== =======================================================
1626+
'on' Toggle axis lines and labels on
1627+
'off' Toggle axis lines and labels off
1628+
'equal' Equal scaling by changing limits
1629+
'scaled' Equal scaling by changing box dimensions
1630+
'tight' Limits set such that all data is shown
1631+
'auto' Automatic scaling, fill rectangle with data
1632+
'image' 'scaled' with axis limits equal to data limits
1633+
'square' Square plot; similar to 'scaled', but initially forcing
1634+
``xmax-xmin = ymax-ymin``
1635+
========== =======================================================
16441636
16451637
xmin, ymin, xmax, ymax : float, optional
16461638
The axis limits to be set
16471639
1640+
emit : bool, optional
1641+
Whether observers are notified of axes limit changes.
1642+
16481643
Returns
16491644
-------
16501645
xmin, xmax, ymin, ymax : float
@@ -1665,17 +1660,15 @@ def axis(self, *v, **kwargs):
16651660
self.set_axis_on()
16661661
elif s == 'off':
16671662
self.set_axis_off()
1668-
elif s in ('equal', 'tight', 'scaled', 'normal',
1669-
'auto', 'image', 'square'):
1663+
elif s in ['equal', 'tight', 'scaled', 'auto', 'image', 'square']:
16701664
self.set_autoscale_on(True)
16711665
self.set_aspect('auto')
16721666
self.autoscale_view(tight=False)
1673-
# self.apply_aspect()
16741667
if s == 'equal':
16751668
self.set_aspect('equal', adjustable='datalim')
16761669
elif s == 'scaled':
16771670
self.set_aspect('equal', adjustable='box', anchor='C')
1678-
self.set_autoscale_on(False) # Req. by Mark Bakker
1671+
self.set_autoscale_on(False)
16791672
elif s == 'tight':
16801673
self.autoscale_view(tight=True)
16811674
self.set_autoscale_on(False)
@@ -3102,14 +3095,14 @@ def set_xscale(self, value, **kwargs):
31023095
"""
31033096
Set the x-axis scale.
31043097
3105-
..
3106-
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3107-
31083098
Parameters
31093099
----------
31103100
value : {"linear", "log", "symlog", "logit"}
31113101
scaling strategy to apply
31123102
3103+
..
3104+
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3105+
31133106
Notes
31143107
-----
31153108
Different kwargs are accepted, depending on the scale. See
@@ -3427,14 +3420,14 @@ def set_yscale(self, value, **kwargs):
34273420
"""
34283421
Set the y-axis scale.
34293422
3430-
..
3431-
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3432-
34333423
Parameters
34343424
----------
34353425
value : {"linear", "log", "symlog", "logit"}
34363426
scaling strategy to apply
34373427
3428+
..
3429+
ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ]
3430+
34383431
Notes
34393432
-----
34403433
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
@@ -1629,7 +1629,7 @@ def _set_artist_props(self, a):
16291629
@docstring.dedent_interpd
16301630
def gca(self, **kwargs):
16311631
"""
1632-
Get the current axes, creating one if necessary
1632+
Get the current axes, creating one if necessary.
16331633
16341634
The following kwargs are supported for ensuring the returned axes
16351635
adheres to the given projection etc., and for axes creation if
@@ -1675,17 +1675,14 @@ def gca(self, **kwargs):
16751675
return self.add_subplot(1, 1, 1, **kwargs)
16761676

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

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

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

20712077
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
@@ -832,7 +832,7 @@ def subplot(*args, **kwargs):
832832
def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
833833
subplot_kw=None, gridspec_kw=None, **fig_kw):
834834
"""
835-
Create a figure and a set of subplots
835+
Create a figure and a set of subplots.
836836
837837
This utility wrapper makes it convenient to create common layouts of
838838
subplots, including the enclosing figure object, in a single call.
@@ -1663,13 +1663,15 @@ def pad(s, l):
16631663
max_name = 0
16641664
max_summary = 0
16651665
for name in commands:
1666-
doc = globals()[name].__doc__
1666+
func = globals()[name]
1667+
doc = inspect.getdoc(func)
16671668
summary = ''
16681669
if doc is not None:
16691670
match = first_sentence.match(doc)
16701671
if match is not None:
16711672
summary = match.group(0).strip().replace('\n', ' ')
1672-
name = '`%s`' % name
1673+
name = ("`{0.__name__}`" if func.__module__ == __name__
1674+
else "`~{0.__module__}.{0.__name__}`").format(func)
16731675
rows.append([name, summary])
16741676
max_name = max(max_name, len(name))
16751677
max_summary = max(max_summary, len(summary))

0 commit comments

Comments
 (0)