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

Skip to content

Commit e3e387a

Browse files
authored
Merge pull request #10834 from timhoffm/doc-axes-spectral
Minor docstring updates on spectral plot functions
2 parents 6af4e4f + f073df7 commit e3e387a

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ def acorr(self, x, **kwargs):
16331633
If ``True``, `Axes.vlines` is used to plot the vertical lines from
16341634
the origin to the acorr. Otherwise, `Axes.plot` is used.
16351635
1636-
maxlags : integer, optional, default: 10
1636+
maxlags : int, optional, default: 10
16371637
Number of lags to show. If ``None``, will return all
16381638
``2 * len(x) - 1`` lags.
16391639
@@ -1654,10 +1654,10 @@ def acorr(self, x, **kwargs):
16541654
16551655
Other Parameters
16561656
----------------
1657-
linestyle : `~matplotlib.lines.Line2D` prop, optional, default: None
1657+
linestyle : `.Line2D` property, optional, default: None
16581658
Only used if usevlines is ``False``.
16591659
1660-
marker : string, optional, default: 'o'
1660+
marker : str, optional, default: 'o'
16611661
16621662
Notes
16631663
-----
@@ -1674,7 +1674,9 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
16741674
"""
16751675
Plot the cross correlation between *x* and *y*.
16761676
1677-
The correlation with lag k is defined as sum_n x[n+k] * conj(y[n]).
1677+
The correlation with lag k is defined as
1678+
:math:`\sum_n x[n+k] \cdot y^*[n]`, where :math:`y^*` is the complex
1679+
conjugate of :math:`y`.
16781680
16791681
Parameters
16801682
----------
@@ -1716,7 +1718,7 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
17161718
17171719
Other Parameters
17181720
----------------
1719-
linestyle : `~matplotlib.lines.Line2D` property, optional
1721+
linestyle : `.Line2D` property, optional
17201722
Only used if usevlines is ``False``.
17211723
17221724
marker : string, optional
@@ -6685,11 +6687,11 @@ def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
66856687
66866688
%(PSD)s
66876689
6688-
noverlap : integer
6690+
noverlap : int
66896691
The number of points of overlap between segments.
66906692
The default value is 0 (no overlap).
66916693
6692-
Fc : integer
6694+
Fc : int
66936695
The center frequency of *x* (defaults to 0), which offsets
66946696
the x extents of the plot to reflect the frequency range used
66956697
when a signal is acquired and then filtered and downsampled to
@@ -6703,10 +6705,10 @@ def psd(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
67036705
-------
67046706
Pxx : 1-D array
67056707
The values for the power spectrum `P_{xx}` before scaling
6706-
(real valued)
6708+
(real valued).
67076709
67086710
freqs : 1-D array
6709-
The frequencies corresponding to the elements in *Pxx*
6711+
The frequencies corresponding to the elements in *Pxx*.
67106712
67116713
line : a :class:`~matplotlib.lines.Line2D` instance
67126714
The line created by this function.
@@ -6807,17 +6809,17 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None,
68076809
Parameters
68086810
----------
68096811
x, y : 1-D arrays or sequences
6810-
Arrays or sequences containing the data
6812+
Arrays or sequences containing the data.
68116813
68126814
%(Spectral)s
68136815
68146816
%(PSD)s
68156817
6816-
noverlap : integer
6818+
noverlap : int
68176819
The number of points of overlap between segments.
68186820
The default value is 0 (no overlap).
68196821
6820-
Fc : integer
6822+
Fc : int
68216823
The center frequency of *x* (defaults to 0), which offsets
68226824
the x extents of the plot to reflect the frequency range used
68236825
when a signal is acquired and then filtered and downsampled to
@@ -6831,10 +6833,10 @@ def csd(self, x, y, NFFT=None, Fs=None, Fc=None, detrend=None,
68316833
-------
68326834
Pxy : 1-D array
68336835
The values for the cross spectrum `P_{xy}` before scaling
6834-
(complex valued)
6836+
(complex valued).
68356837
68366838
freqs : 1-D array
6837-
The frequencies corresponding to the elements in *Pxy*
6839+
The frequencies corresponding to the elements in *Pxy*.
68386840
68396841
line : a :class:`~matplotlib.lines.Line2D` instance
68406842
The line created by this function.
@@ -6913,18 +6915,18 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None,
69136915
Parameters
69146916
----------
69156917
x : 1-D array or sequence
6916-
Array or sequence containing the data
6918+
Array or sequence containing the data.
69176919
69186920
%(Spectral)s
69196921
69206922
%(Single_Spectrum)s
69216923
6922-
scale : [ 'default' | 'linear' | 'dB' ]
6924+
scale : {'default', 'linear', 'dB'}
69236925
The scaling of the values in the *spec*. 'linear' is no scaling.
69246926
'dB' returns the values in dB scale, i.e., the dB amplitude
69256927
(20 * log10). 'default' is 'linear'.
69266928
6927-
Fc : integer
6929+
Fc : int
69286930
The center frequency of *x* (defaults to 0), which offsets
69296931
the x extents of the plot to reflect the frequency range used
69306932
when a signal is acquired and then filtered and downsampled to
@@ -6933,13 +6935,13 @@ def magnitude_spectrum(self, x, Fs=None, Fc=None, window=None,
69336935
Returns
69346936
-------
69356937
spectrum : 1-D array
6936-
The values for the magnitude spectrum before scaling (real valued)
6938+
The values for the magnitude spectrum before scaling (real valued).
69376939
69386940
freqs : 1-D array
6939-
The frequencies corresponding to the elements in *spectrum*
6941+
The frequencies corresponding to the elements in *spectrum*.
69406942
69416943
line : a :class:`~matplotlib.lines.Line2D` instance
6942-
The line created by this function
6944+
The line created by this function.
69436945
69446946
Other Parameters
69456947
----------------
@@ -7018,13 +7020,13 @@ def angle_spectrum(self, x, Fs=None, Fc=None, window=None,
70187020
Parameters
70197021
----------
70207022
x : 1-D array or sequence
7021-
Array or sequence containing the data
7023+
Array or sequence containing the data.
70227024
70237025
%(Spectral)s
70247026
70257027
%(Single_Spectrum)s
70267028
7027-
Fc : integer
7029+
Fc : int
70287030
The center frequency of *x* (defaults to 0), which offsets
70297031
the x extents of the plot to reflect the frequency range used
70307032
when a signal is acquired and then filtered and downsampled to
@@ -7033,13 +7035,13 @@ def angle_spectrum(self, x, Fs=None, Fc=None, window=None,
70337035
Returns
70347036
-------
70357037
spectrum : 1-D array
7036-
The values for the angle spectrum in radians (real valued)
7038+
The values for the angle spectrum in radians (real valued).
70377039
70387040
freqs : 1-D array
7039-
The frequencies corresponding to the elements in *spectrum*
7041+
The frequencies corresponding to the elements in *spectrum*.
70407042
70417043
line : a :class:`~matplotlib.lines.Line2D` instance
7042-
The line created by this function
7044+
The line created by this function.
70437045
70447046
Other Parameters
70457047
----------------
@@ -7109,7 +7111,7 @@ def phase_spectrum(self, x, Fs=None, Fc=None, window=None,
71097111
71107112
%(Single_Spectrum)s
71117113
7112-
Fc : integer
7114+
Fc : int
71137115
The center frequency of *x* (defaults to 0), which offsets
71147116
the x extents of the plot to reflect the frequency range used
71157117
when a signal is acquired and then filtered and downsampled to
@@ -7118,13 +7120,13 @@ def phase_spectrum(self, x, Fs=None, Fc=None, window=None,
71187120
Returns
71197121
-------
71207122
spectrum : 1-D array
7121-
The values for the phase spectrum in radians (real valued)
7123+
The values for the phase spectrum in radians (real valued).
71227124
71237125
freqs : 1-D array
7124-
The frequencies corresponding to the elements in *spectrum*
7126+
The frequencies corresponding to the elements in *spectrum*.
71257127
71267128
line : a :class:`~matplotlib.lines.Line2D` instance
7127-
The line created by this function
7129+
The line created by this function.
71287130
71297131
Other Parameters
71307132
----------------
@@ -7189,11 +7191,11 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
71897191
71907192
%(PSD)s
71917193
7192-
noverlap : integer
7194+
noverlap : int
71937195
The number of points of overlap between blocks. The
71947196
default value is 0 (no overlap).
71957197
7196-
Fc : integer
7198+
Fc : int
71977199
The center frequency of *x* (defaults to 0), which offsets
71987200
the x extents of the plot to reflect the frequency range used
71997201
when a signal is acquired and then filtered and downsampled to
@@ -7202,10 +7204,11 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
72027204
72037205
Returns
72047206
-------
7205-
The return value is a tuple (*Cxy*, *f*), where *f* are the
7206-
frequencies of the coherence vector.
7207+
Cxy : 1-D array
7208+
The coherence vector.
72077209
7208-
kwargs are applied to the lines.
7210+
freqs : 1-D array
7211+
The frequencies for the elements in *Cxy*.
72097212
72107213
Other Parameters
72117214
----------------
@@ -7268,26 +7271,26 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
72687271
72697272
%(PSD)s
72707273
7271-
mode : [ 'default' | 'psd' | 'magnitude' | 'angle' | 'phase' ]
7274+
mode : {'default', 'psd', 'magnitude', 'angle', 'phase'}
72727275
What sort of spectrum to use. Default is 'psd', which takes
72737276
the power spectral density. 'complex' returns the complex-valued
72747277
frequency spectrum. 'magnitude' returns the magnitude spectrum.
72757278
'angle' returns the phase spectrum without unwrapping. 'phase'
72767279
returns the phase spectrum with unwrapping.
72777280
7278-
noverlap : integer
7281+
noverlap : int
72797282
The number of points of overlap between blocks. The
72807283
default value is 128.
72817284
7282-
scale : [ 'default' | 'linear' | 'dB' ]
7285+
scale : {'default', 'linear', 'dB'}
72837286
The scaling of the values in the *spec*. 'linear' is no scaling.
72847287
'dB' returns the values in dB scale. When *mode* is 'psd',
72857288
this is dB power (10 * log10). Otherwise this is dB amplitude
72867289
(20 * log10). 'default' is 'dB' if *mode* is 'psd' or
72877290
'magnitude' and 'linear' otherwise. This must be 'linear'
72887291
if *mode* is 'angle' or 'phase'.
72897292
7290-
Fc : integer
7293+
Fc : int
72917294
The center frequency of *x* (defaults to 0), which offsets
72927295
the x extents of the plot to reflect the frequency range used
72937296
when a signal is acquired and then filtered and downsampled to
@@ -7297,15 +7300,15 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
72977300
A :class:`matplotlib.colors.Colormap` instance; if *None*, use
72987301
default determined by rc
72997302
7300-
xextent : [None | (xmin, xmax)]
7303+
xextent : *None* or (xmin, xmax)
73017304
The image extent along the x-axis. The default sets *xmin* to the
73027305
left border of the first bin (*spectrum* column) and *xmax* to the
73037306
right border of the last bin. Note that for *noverlap>0* the width
73047307
of the bins is smaller than those of the segments.
73057308
73067309
**kwargs :
73077310
Additional kwargs are passed on to imshow which makes the
7308-
specgram image
7311+
specgram image.
73097312
73107313
Returns
73117314
-------

lib/matplotlib/mlab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
810810
argument, it must take a data segment as an argument and
811811
return the windowed version of the segment.
812812
813-
sides : [ 'default' | 'onesided' | 'twosided' ]
813+
sides : {'default', 'onesided', 'twosided'}
814814
Specifies which sides of the spectrum to return. Default gives the
815815
default behavior, which returns one-sided for real data and both
816816
for complex data. 'onesided' forces the return of a one-sided
@@ -819,7 +819,7 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
819819

820820

821821
docstring.interpd.update(Single_Spectrum=cbook.dedent("""
822-
pad_to : integer
822+
pad_to : int
823823
The number of points to which the data segment is padded when
824824
performing the FFT. While not increasing the actual resolution of
825825
the spectrum (the minimum distance between resolvable peaks),
@@ -831,7 +831,7 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
831831

832832

833833
docstring.interpd.update(PSD=cbook.dedent("""
834-
pad_to : integer
834+
pad_to : int
835835
The number of points to which the data segment is padded when
836836
performing the FFT. This can be different from *NFFT*, which
837837
specifies the number of data points used. While not increasing
@@ -841,7 +841,7 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
841841
in the call to fft(). The default is None, which sets *pad_to*
842842
equal to *NFFT*
843843
844-
NFFT : integer
844+
NFFT : int
845845
The number of data points used in each block for the FFT.
846846
A power 2 is most efficient. The default value is 256.
847847
This should *NOT* be used to get zero padding, or the scaling of the
@@ -861,7 +861,7 @@ def _single_spectrum_helper(x, mode, Fs=None, window=None, pad_to=None,
861861
:func:`~matplotlib.pylab.detrend_linear`. 'none' calls
862862
:func:`~matplotlib.pylab.detrend_none`.
863863
864-
scale_by_freq : boolean, optional
864+
scale_by_freq : bool, optional
865865
Specifies whether the resulting density values should be scaled
866866
by the scaling frequency, which gives density in units of Hz^-1.
867867
This allows for integration over the returned frequency values.

0 commit comments

Comments
 (0)