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

Skip to content

Commit 6547c12

Browse files
authored
Merge pull request #10366 from timhoffm/axes-doc-datanotes
Axes doc datanotes
2 parents 005a603 + 7b7df5d commit 6547c12

2 files changed

Lines changed: 81 additions & 65 deletions

File tree

lib/matplotlib/axes/_axes.py

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,11 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
676676
677677
%(Line2D)s
678678
679+
See also
680+
--------
681+
hlines : add horizontal lines in data coordinates
682+
axhspan : add a horizontal span (rectangle) across the axis
683+
679684
Notes
680685
-----
681686
kwargs are passed to :class:`~matplotlib.lines.Line2D` and can be used
@@ -697,12 +702,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
697702
698703
>>> axhline(y=.5, xmin=0.25, xmax=0.75)
699704
700-
See also
701-
--------
702-
hlines : add horizontal lines in data coordinates
703-
axhspan : add a horizontal span (rectangle) across the axis
704705
"""
705-
706706
if "transform" in kwargs:
707707
raise ValueError(
708708
"'transform' is not allowed as a kwarg;"
@@ -2826,10 +2826,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
28262826
-----
28272827
The pie chart will probably look best if the figure and axes are
28282828
square, or the Axes aspect is equal.
2829-
2830-
28312829
"""
2832-
28332830
x = np.array(x, np.float32)
28342831

28352832
sx = x.sum()
@@ -4457,7 +4454,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
44574454
to the return collection as attributes *hbar* and *vbar*.
44584455
44594456
Notes
4460-
--------
4457+
-----
44614458
The standard descriptions of all the
44624459
:class:`~matplotlib.collections.Collection` parameters:
44634460
@@ -6405,6 +6402,10 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64056402
--------
64066403
hist2d : 2D histograms
64076404
6405+
Notes
6406+
-----
6407+
.. [Notes section required for data comment. See #10189.]
6408+
64086409
"""
64096410
# Avoid shadowing the builtin.
64106411
bin_range = range
@@ -6884,17 +6885,6 @@ def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
68846885
68856886
%(Line2D)s
68866887
6887-
Notes
6888-
-----
6889-
For plotting, the power is plotted as
6890-
:math:`10\log_{10}(P_{xx})` for decibels, though *Pxx* itself
6891-
is returned.
6892-
6893-
References
6894-
----------
6895-
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
6896-
John Wiley & Sons (1986)
6897-
68986888
See Also
68996889
--------
69006890
:func:`specgram`
@@ -6907,6 +6897,17 @@ def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
69076897
69086898
:func:`csd`
69096899
:func:`csd` plots the spectral density between two signals.
6900+
6901+
Notes
6902+
-----
6903+
For plotting, the power is plotted as
6904+
:math:`10\log_{10}(P_{xx})` for decibels, though *Pxx* itself
6905+
is returned.
6906+
6907+
References
6908+
----------
6909+
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
6910+
John Wiley & Sons (1986)
69106911
"""
69116912
if not self._hold:
69126913
self.cla()
@@ -7012,6 +7013,11 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None,
70127013
70137014
%(Line2D)s
70147015
7016+
See Also
7017+
--------
7018+
:func:`psd`
7019+
:func:`psd` is the equivalent to setting y=x.
7020+
70157021
Notes
70167022
-----
70177023
For plotting, the power is plotted as
@@ -7022,11 +7028,6 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None,
70227028
----------
70237029
Bendat & Piersol -- Random Data: Analysis and Measurement Procedures,
70247030
John Wiley & Sons (1986)
7025-
7026-
See Also
7027-
--------
7028-
:func:`psd`
7029-
:func:`psd` is the equivalent to setting y=x.
70307031
"""
70317032
if not self._hold:
70327033
self.cla()
@@ -7129,6 +7130,11 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None,
71297130
:func:`specgram`
71307131
:func:`specgram` can plot the magnitude spectrum of segments within
71317132
the signal in a colormap.
7133+
7134+
Notes
7135+
-----
7136+
.. [Notes section required for data comment. See #10189.]
7137+
71327138
"""
71337139
if not self._hold:
71347140
self.cla()
@@ -7221,6 +7227,11 @@ def angle_spectrum(self, x, Fs=None, Fc=None, window=None,
72217227
:func:`specgram`
72227228
:func:`specgram` can plot the angle spectrum of segments within the
72237229
signal in a colormap.
7230+
7231+
Notes
7232+
-----
7233+
.. [Notes section required for data comment. See #10189.]
7234+
72247235
"""
72257236
if not self._hold:
72267237
self.cla()
@@ -7300,6 +7311,11 @@ def phase_spectrum(self, x, Fs=None, Fc=None, window=None,
73007311
:func:`specgram`
73017312
:func:`specgram` can plot the phase spectrum of segments within the
73027313
signal in a colormap.
7314+
7315+
Notes
7316+
-----
7317+
.. [Notes section required for data comment. See #10189.]
7318+
73037319
"""
73047320
if not self._hold:
73057321
self.cla()
@@ -7456,11 +7472,6 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
74567472
Additional kwargs are passed on to imshow which makes the
74577473
specgram image
74587474
7459-
Notes
7460-
-----
7461-
*detrend* and *scale_by_freq* only apply when *mode* is set to
7462-
'psd'
7463-
74647475
Returns
74657476
-------
74667477
spectrum : 2-D array
@@ -7494,6 +7505,11 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
74947505
:func:`phase_spectrum`
74957506
A single spectrum, similar to having a single segment when *mode*
74967507
is 'phase'. Plots a line instead of a colormap.
7508+
7509+
Notes
7510+
-----
7511+
The parameters *detrend* and *scale_by_freq* do only apply when *mode*
7512+
is set to 'psd'.
74977513
"""
74987514
if not self._hold:
74997515
self.cla()
@@ -7788,6 +7804,11 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
77887804
:class:`matplotlib.collections.LineCollection` instance
77897805
created to identify the median values of each of the
77907806
violin's distribution.
7807+
7808+
Notes
7809+
-----
7810+
.. [Notes section required for data comment. See #10189.]
7811+
77917812
"""
77927813

77937814
def _kde_method(X, coords):

lib/matplotlib/figure.py

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None):
624624
625625
Parameters
626626
----------
627-
628627
bottom : scalar
629628
The bottom of the subplots for :meth:`subplots_adjust`
630629
@@ -660,7 +659,7 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None):
660659
self.stale = True
661660

662661
def get_children(self):
663-
'get a list of artists contained in the figure'
662+
"""Get a list of artists contained in the figure."""
664663
children = [self.patch]
665664
children.extend(self.artists)
666665
children.extend(self.axes)
@@ -683,9 +682,9 @@ def contains(self, mouseevent):
683682
return inside, {}
684683

685684
def get_window_extent(self, *args, **kwargs):
686-
''''
685+
"""
687686
Return figure bounding box in display space; arguments are ignored.
688-
'''
687+
"""
689688
return self.bbox
690689

691690
def suptitle(self, t, **kwargs):
@@ -886,7 +885,6 @@ def set_size_inches(self, w, h=None, forward=True):
886885
887886
See Also
888887
--------
889-
890888
matplotlib.Figure.get_size_inches
891889
"""
892890

@@ -923,33 +921,32 @@ def get_size_inches(self):
923921
924922
See Also
925923
--------
926-
927924
matplotlib.Figure.set_size_inches
928925
"""
929926
return np.array(self.bbox_inches.p1)
930927

931928
def get_edgecolor(self):
932-
'Get the edge color of the Figure rectangle'
929+
"""Get the edge color of the Figure rectangle."""
933930
return self.patch.get_edgecolor()
934931

935932
def get_facecolor(self):
936-
'Get the face color of the Figure rectangle'
933+
"""Get the face color of the Figure rectangle."""
937934
return self.patch.get_facecolor()
938935

939936
def get_figwidth(self):
940-
'Return the figwidth as a float'
937+
"""Return the figwidth as a float."""
941938
return self.bbox_inches.width
942939

943940
def get_figheight(self):
944-
'Return the figheight as a float'
941+
"""Return the figheight as a float."""
945942
return self.bbox_inches.height
946943

947944
def get_dpi(self):
948-
'Return the dpi as a float'
945+
"""Return the dpi as a float."""
949946
return self.dpi
950947

951948
def get_frameon(self):
952-
'get the boolean indicating frameon'
949+
"""Get the boolean indicating frameon."""
953950
return self.frameon
954951

955952
def set_edgecolor(self, color):
@@ -1012,7 +1009,7 @@ def delaxes(self, ax):
10121009
self.stale = True
10131010

10141011
def _make_key(self, *args, **kwargs):
1015-
'make a hashable key out of args and kwargs'
1012+
"""Make a hashable key out of args and kwargs."""
10161013

10171014
def fixitems(items):
10181015
# items may have arrays and lists in them, so convert them
@@ -1483,8 +1480,8 @@ def draw(self, renderer):
14831480

14841481
def draw_artist(self, a):
14851482
"""
1486-
draw :class:`matplotlib.artist.Artist` instance *a* only --
1487-
this is available only after the figure is drawn
1483+
Draw :class:`matplotlib.artist.Artist` instance *a* only.
1484+
This is available only after the figure is drawn.
14881485
"""
14891486
if self._cachedRenderer is None:
14901487
raise AttributeError("draw_artist can only be used after an "
@@ -1817,16 +1814,15 @@ def gca(self, **kwargs):
18171814
return self.add_subplot(1, 1, 1, **kwargs)
18181815

18191816
def sca(self, a):
1820-
'Set the current axes to be a and return a'
1817+
"""Set the current axes to be a and return a."""
18211818
self._axstack.bubble(a)
18221819
for func in self._axobservers:
18231820
func(self)
18241821
return a
18251822

18261823
def _gci(self):
18271824
"""
1828-
helper for :func:`~matplotlib.pyplot.gci`;
1829-
do not use elsewhere.
1825+
Helper for :func:`~matplotlib.pyplot.gci`. Do not use elsewhere.
18301826
"""
18311827
# Look first for an image in the current Axes:
18321828
cax = self._axstack.current_key_axes()[1]
@@ -1924,7 +1920,7 @@ def make_active(event):
19241920
self.stale = True
19251921

19261922
def add_axobserver(self, func):
1927-
'whenever the axes state change, ``func(self)`` will be called'
1923+
"""Whenever the axes state change, ``func(self)`` will be called."""
19281924
self._axobservers.append(func)
19291925

19301926
def savefig(self, fname, **kwargs):
@@ -2083,7 +2079,7 @@ def subplots_adjust(self, *args, **kwargs):
20832079
wspace=None, hspace=None)
20842080
20852081
Update the :class:`SubplotParams` with *kwargs* (defaulting to rc when
2086-
*None*) and update the subplot locations
2082+
*None*) and update the subplot locations.
20872083
20882084
"""
20892085
self.subplotpars.update(*args, **kwargs)
@@ -2246,7 +2242,6 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
22462242
22472243
Parameters
22482244
----------
2249-
22502245
pad : float
22512246
padding between the figure edge and the edges of subplots,
22522247
as a fraction of the font-size.
@@ -2296,19 +2291,19 @@ def align_xlabels(self, axs=None):
22962291
Optional list of (or ndarray) `~matplotlib.axes.Axes` to align
22972292
the xlabels. Default is to align all axes on the figure.
22982293
2299-
Note
2300-
----
2301-
This assumes that ``axs`` are from the same `~.GridSpec`, so that
2302-
their `~.SubplotSpec` positions correspond to figure positions.
2303-
23042294
See Also
23052295
--------
23062296
matplotlib.figure.Figure.align_ylabels
23072297
23082298
matplotlib.figure.Figure.align_labels
23092299
2310-
Example
2311-
-------
2300+
Notes
2301+
-----
2302+
This assumes that ``axs`` are from the same `~.GridSpec`, so that
2303+
their `~.SubplotSpec` positions correspond to figure positions.
2304+
2305+
Examples
2306+
--------
23122307
Example with rotated xtick labels::
23132308
23142309
fig, axs = plt.subplots(1, 2)
@@ -2364,19 +2359,19 @@ def align_ylabels(self, axs=None):
23642359
Optional list (or ndarray) of `~matplotlib.axes.Axes` to align
23652360
the ylabels. Default is to align all axes on the figure.
23662361
2367-
Note
2368-
----
2369-
This assumes that ``axs`` are from the same `~.GridSpec`, so that
2370-
their `~.SubplotSpec` positions correspond to figure positions.
2371-
23722362
See Also
23732363
--------
23742364
matplotlib.figure.Figure.align_xlabels
23752365
23762366
matplotlib.figure.Figure.align_labels
23772367
2378-
Example
2379-
-------
2368+
Notes
2369+
-----
2370+
This assumes that ``axs`` are from the same `~.GridSpec`, so that
2371+
their `~.SubplotSpec` positions correspond to figure positions.
2372+
2373+
Examples
2374+
--------
23802375
Example with large yticks labels::
23812376
23822377
fig, axs = plt.subplots(2, 1)

0 commit comments

Comments
 (0)