@@ -7104,14 +7104,14 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
71047104 Parameters
71057105 ----------
71067106 x : 1-D array or sequence
7107- Array or sequence containing the data
7107+ Array or sequence containing the data.
71087108
71097109 %(Spectral)s
71107110
71117111 %(PSD)s
71127112
71137113 mode : [ 'default' | 'psd' | 'magnitude' | 'angle' | 'phase' ]
7114- What sort of spectrum to use. Default is 'psd'. which takes
7114+ What sort of spectrum to use. Default is 'psd', which takes
71157115 the power spectral density. 'complex' returns the complex-valued
71167116 frequency spectrum. 'magnitude' returns the magnitude spectrum.
71177117 'angle' returns the phase spectrum without unwrapping. 'phase'
@@ -7139,10 +7139,11 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
71397139 A :class:`matplotlib.colors.Colormap` instance; if *None*, use
71407140 default determined by rc
71417141
7142- xextent :
7143- The image extent along the x-axis. xextent = (xmin,xmax)
7144- The default is (0,max(bins)), where bins is the return
7145- value from :func:`~matplotlib.mlab.specgram`
7142+ xextent : [None | (xmin, xmax)]
7143+ The image extent along the x-axis. The default sets *xmin* to the
7144+ left border of the first bin (*spectrum* column) and *xmax* to the
7145+ right border of the last bin. Note that for *noverlap>0* the width
7146+ of the bins is smaller than those of the segments.
71467147
71477148 **kwargs :
71487149 Additional kwargs are passed on to imshow which makes the
@@ -7156,14 +7157,14 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
71567157 Returns
71577158 -------
71587159 spectrum : 2-D array
7159- columns are the periodograms of successive segments
7160+ Columns are the periodograms of successive segments.
71607161
71617162 freqs : 1-D array
7162- The frequencies corresponding to the rows in *spectrum*
7163+ The frequencies corresponding to the rows in *spectrum*.
71637164
71647165 t : 1-D array
7165- The times corresponding to midpoints of segments (i.e the columns
7166- in *spectrum*)
7166+ The times corresponding to midpoints of segments (i.e., the columns
7167+ in *spectrum*).
71677168
71687169 im : instance of class :class:`~matplotlib.image.AxesImage`
71697170 The image created by imshow containing the spectrogram
@@ -7228,7 +7229,9 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
72287229 Z = np .flipud (Z )
72297230
72307231 if xextent is None :
7231- xextent = 0 , np .max (t )
7232+ # padding is needed for first and last segment:
7233+ pad_xextnt = (NFFT - noverlap ) / Fs / 2
7234+ xextent = np .min (t ) - pad_xextnt , np .max (t ) + pad_xextnt
72327235 xmin , xmax = xextent
72337236 freqs += Fc
72347237 extent = xmin , xmax , freqs [0 ], freqs [- 1 ]
0 commit comments