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

Skip to content

Commit 6b8438e

Browse files
committed
Fix docstrings affected by move to dynamic pyplot.
1 parent 7a99bec commit 6b8438e

File tree

4 files changed

+54
-62
lines changed

4 files changed

+54
-62
lines changed

lib/matplotlib/axes/_axes.py

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

231231
def set_ylabel(self, ylabel, fontdict=None, labelpad=None, **kwargs):
232232
"""
233-
Set the label for the yaxis
233+
Set the label for the yaxis.
234234
235235
Parameters
236236
----------

lib/matplotlib/axes/_base.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,45 +1488,40 @@ def apply_aspect(self, position=None):
14881488
self.set_xbound((x0, x1))
14891489

14901490
def axis(self, *v, **kwargs):
1491-
"""Set axis properties.
1491+
"""Convenience method to get or set axis properties.
14921492
14931493
Valid signatures::
14941494
1495-
xmin, xmax, ymin, ymax = axis()
1496-
xmin, xmax, ymin, ymax = axis(list_arg)
1497-
xmin, xmax, ymin, ymax = axis(string_arg)
1498-
xmin, xmax, ymin, ymax = axis(**kwargs)
1495+
xmin, xmax, ymin, ymax = axis(*, emit=True)
1496+
xmin, xmax, ymin, ymax = axis(_string_arg_, *, emit=True)
1497+
xmin, xmax, ymin, ymax = axis([xmin, ymin, xmax, ymax], *, emit=True)
14991498
15001499
Parameters
15011500
----------
1502-
v : list of float or {'on', 'off', 'equal', 'tight', 'scaled',\
1503-
'normal', 'auto', 'image', 'square'}
1504-
Optional positional argument
1505-
1506-
Axis data limits set from a list; or a command relating to axes:
1507-
1508-
========== ================================================
1509-
Value Description
1510-
========== ================================================
1511-
'on' Toggle axis lines and labels on
1512-
'off' Toggle axis lines and labels off
1513-
'equal' Equal scaling by changing limits
1514-
'scaled' Equal scaling by changing box dimensions
1515-
'tight' Limits set such that all data is shown
1516-
'auto' Automatic scaling, fill rectangle with data
1517-
'normal' Same as 'auto'; deprecated
1518-
'image' 'scaled' with axis limits equal to data limits
1519-
'square' Square plot; similar to 'scaled', but initially\
1520-
forcing xmax-xmin = ymax-ymin
1521-
========== ================================================
1522-
1523-
emit : bool, optional
1524-
Passed to set_{x,y}lim functions, if observers
1525-
are notified of axis limit change
1501+
_string_arg_ : str, optional
1502+
1503+
The following values are allowed:
1504+
1505+
========== =======================================================
1506+
Value Description
1507+
========== =======================================================
1508+
'on' Toggle axis lines and labels on
1509+
'off' Toggle axis lines and labels off
1510+
'equal' Equal scaling by changing limits
1511+
'scaled' Equal scaling by changing box dimensions
1512+
'tight' Limits set such that all data is shown
1513+
'auto' Automatic scaling, fill rectangle with data
1514+
'image' 'scaled' with axis limits equal to data limits
1515+
'square' Square plot; similar to 'scaled', but initially forcing
1516+
``xmax-xmin = ymax-ymin``
1517+
========== =======================================================
15261518
15271519
xmin, ymin, xmax, ymax : float, optional
15281520
The axis limits to be set
15291521
1522+
emit : bool, optional
1523+
Whether observers are notified of axes limit changes.
1524+
15301525
Returns
15311526
-------
15321527
xmin, xmax, ymin, ymax : float
@@ -1547,17 +1542,15 @@ def axis(self, *v, **kwargs):
15471542
self.set_axis_on()
15481543
elif s == 'off':
15491544
self.set_axis_off()
1550-
elif s in ('equal', 'tight', 'scaled', 'normal',
1551-
'auto', 'image', 'square'):
1545+
elif s in ['equal', 'tight', 'scaled', 'auto', 'image', 'square']:
15521546
self.set_autoscale_on(True)
15531547
self.set_aspect('auto')
15541548
self.autoscale_view(tight=False)
1555-
# self.apply_aspect()
15561549
if s == 'equal':
15571550
self.set_aspect('equal', adjustable='datalim')
15581551
elif s == 'scaled':
15591552
self.set_aspect('equal', adjustable='box', anchor='C')
1560-
self.set_autoscale_on(False) # Req. by Mark Bakker
1553+
self.set_autoscale_on(False)
15611554
elif s == 'tight':
15621555
self.autoscale_view(tight=True)
15631556
self.set_autoscale_on(False)
@@ -2950,7 +2943,7 @@ def get_xscale(self):
29502943

29512944
def set_xscale(self, value, **kwargs):
29522945
"""
2953-
Set the x-axis scale
2946+
Set the x-axis scale.
29542947
29552948
Parameters
29562949
----------
@@ -3257,7 +3250,7 @@ def get_yscale(self):
32573250

32583251
def set_yscale(self, value, **kwargs):
32593252
"""
3260-
Set the y-axis scale
3253+
Set the y-axis scale.
32613254
32623255
Parameters
32633256
----------

lib/matplotlib/figure.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ def _set_artist_props(self, a):
15641564
@docstring.dedent_interpd
15651565
def gca(self, **kwargs):
15661566
"""
1567-
Get the current axes, creating one if necessary
1567+
Get the current axes, creating one if necessary.
15681568
15691569
The following kwargs are supported for ensuring the returned axes
15701570
adheres to the given projection etc., and for axes creation if
@@ -1610,17 +1610,14 @@ def gca(self, **kwargs):
16101610
return self.add_subplot(1, 1, 1, **kwargs)
16111611

16121612
def sca(self, a):
1613-
'Set the current axes to be a and return a'
1613+
"""Set the current axes to be a and return a."""
16141614
self._axstack.bubble(a)
16151615
for func in self._axobservers:
16161616
func(self)
16171617
return a
16181618

16191619
def _gci(self):
1620-
"""
1621-
helper for :func:`~matplotlib.pyplot.gci`;
1622-
do not use elsewhere.
1623-
"""
1620+
"""Get the current colorable artist."""
16241621
# Look first for an image in the current Axes:
16251622
cax = self._axstack.current_key_axes()[1]
16261623
if cax is None:
@@ -1974,20 +1971,20 @@ def get_tightbbox(self, renderer):
19741971
def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
19751972
rect=None):
19761973
"""
1977-
Adjust subplot parameters to give specified padding.
1978-
1979-
Parameters:
1974+
Automatically adjust subplot parameters to give specified padding.
19801975
1981-
pad : float
1982-
padding between the figure edge and the edges of subplots,
1983-
as a fraction of the font-size.
1984-
h_pad, w_pad : float
1985-
padding (height/width) between edges of adjacent subplots.
1976+
Parameters
1977+
----------
1978+
pad : float, optional
1979+
Padding between the figure edge and the edges of subplots, as a
1980+
fraction of the font-size.
1981+
h_pad, w_pad : float, optional
1982+
Padding (height/width) between edges of adjacent subplots.
19861983
Defaults to `pad_inches`.
1987-
rect : if rect is given, it is interpreted as a rectangle
1988-
(left, bottom, right, top) in the normalized figure
1989-
coordinate that the whole subplots area (including
1990-
labels) will fit into. Default is (0, 0, 1, 1).
1984+
rect : Tuple[float, float, float, float], optional
1985+
(left, bottom, right, top) rectangle in normalized figure
1986+
coordinates that the whole subplots area (including labels) will
1987+
fit into. Defaults to using the entire figure.
19911988
"""
19921989

19931990
from .tight_layout import (

lib/matplotlib/pyplot.py

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

114114
def install_repl_displayhook():
115115
"""
116-
Install a repl display hook so that any stale figure are automatically
117-
redrawn when control is returned to the repl.
116+
Install a REPL display hook so that any stale figure are automatically
117+
redrawn when control is returned to the REPL.
118118
119-
This works with IPython terminals and kernels,
120-
as well as vanilla python shells.
119+
This works with IPython terminals and kernels, as well as vanilla Python
120+
shells.
121121
"""
122122
global _IP_REGISTERED
123123
global _INSTALL_FIG_OBSERVER
@@ -167,7 +167,7 @@ def post_execute():
167167

168168
def uninstall_repl_displayhook():
169169
"""
170-
Uninstalls the matplotlib display hook.
170+
Uninstall the matplotlib display hook.
171171
172172
.. warning
173173
@@ -823,7 +823,7 @@ def subplot(*args, **kwargs):
823823
def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
824824
subplot_kw=None, gridspec_kw=None, **fig_kw):
825825
"""
826-
Create a figure and a set of subplots
826+
Create a figure and a set of subplots.
827827
828828
This utility wrapper makes it convenient to create common layouts of
829829
subplots, including the enclosing figure object, in a single call.
@@ -1628,13 +1628,15 @@ def pad(s, l):
16281628
max_name = 0
16291629
max_summary = 0
16301630
for name in commands:
1631-
doc = globals()[name].__doc__
1631+
func = globals()[name]
1632+
doc = inspect.getdoc(func)
16321633
summary = ''
16331634
if doc is not None:
16341635
match = first_sentence.match(doc)
16351636
if match is not None:
16361637
summary = match.group(0).strip().replace('\n', ' ')
1637-
name = '`%s`' % name
1638+
name = ("`{0.__name__}`" if func.__module__ == __name__
1639+
else "`~{0.__module__}.{0.__name__}`").format(func)
16381640
rows.append([name, summary])
16391641
max_name = max(max_name, len(name))
16401642
max_summary = max(max_summary, len(summary))

0 commit comments

Comments
 (0)