matplotlib.mlab

Numerical python functions written for compatibility with MATLAB commands with the same names. Most numerical python functions can be found in the numpy and scipy libraries. What remains here is code for performing spectral computations.

Spectral functions

cohere
Coherence (normalized cross spectral density)
csd
Cross spectral density using Welch's average periodogram
detrend
Remove the mean or best fit line from an array
psd
Power spectral density using Welch's average periodogram
specgram
Spectrogram (spectrum over segments of time)
complex_spectrum
Return the complex-valued frequency spectrum of a signal
magnitude_spectrum
Return the magnitude of the frequency spectrum of a signal
angle_spectrum
Return the angle (wrapped phase) of the frequency spectrum of a signal
phase_spectrum
Return the phase (unwrapped angle) of the frequency spectrum of a signal
detrend_mean
Remove the mean from a line.
detrend_linear
Remove the best fit line from a line.
detrend_none
Return the original line.
stride_windows
Get all windows in an array in a memory-efficient manner
stride_repeat
Repeat an array in a memory-efficient manner
apply_window
Apply a window along a given axis
class matplotlib.mlab.GaussianKDE(dataset, bw_method=None)[source]

Bases: object

Representation of a kernel-density estimate using Gaussian kernels.

Parameters:
datasetarray-like

Datapoints to estimate from. In case of univariate data this is a 1-D array, otherwise a 2-D array with shape (# of dims, # of data).

bw_methodstr, scalar or callable, optional

The method used to calculate the estimator bandwidth. This can be 'scott', 'silverman', a scalar constant or a callable. If a scalar, this will be used directly as kde.factor. If a callable, it should take a GaussianKDE instance as only parameter and return a scalar. If None (default), 'scott' is used.

Attributes:
datasetndarray

The dataset with which gaussian_kde was initialized.

dimint

Number of dimensions.

num_dpint

Number of datapoints.

factorfloat

The bandwidth factor, obtained from kde.covariance_factor, with which the covariance matrix is multiplied.

covariancendarray

The covariance matrix of dataset, scaled by the calculated bandwidth (kde.factor).

inv_covndarray

The inverse of covariance.

Methods

kde.evaluate(points) (ndarray) Evaluate the estimated pdf on a provided set of points.
kde(points) (ndarray) Same as kde.evaluate(points)
covariance_factor(self)
evaluate(self, points)[source]

Evaluate the estimated pdf on a set of points.

Parameters:
points(# of dimensions, # of points)-array

Alternatively, a (# of dimensions,) vector can be passed in and treated as a single point.

Returns:
values(# of points,)-array

The values at each point.

Raises:
ValueErrorif the dimensionality of the input points is different

than the dimensionality of the KDE.

scotts_factor(self)[source]
silverman_factor(self)[source]
matplotlib.mlab.angle_spectrum(x, Fs=None, window=None, pad_to=None, sides=None)[source]

Compute the angle of the frequency spectrum (wrapped phase spectrum) of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.

Parameters:
x1-D array or sequence

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).

Returns:
spectrum1-D array

The values for the angle spectrum in radians (real valued)

freqs1-D array

The frequencies corresponding to the elements in spectrum

See also

complex_spectrum
This function returns the angle value of complex_spectrum.
magnitude_spectrum
Returns the magnitudes of the corresponding frequencies.
phase_spectrum
Returns the phase (unwrapped angle) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
matplotlib.mlab.apply_window(x, window, axis=0, return_window=None)[source]

[Deprecated] Apply the given window to the given 1D or 2D array along the given axis.

Parameters:
x1D or 2D array or sequence

Array or sequence containing the data.

windowfunction or array.

Either a function to generate a window or an array with length x.shape[axis]

axisinteger

The axis over which to do the repetition. Must be 0 or 1. The default is 0

return_windowbool

If true, also return the 1D values of the window that was applied

Notes

Deprecated since version 3.2.

matplotlib.mlab.cohere(x, y, NFFT=256, Fs=2, detrend=<function detrend_none at 0x7f65b0d01290>, window=<function window_hanning at 0x7f65ac56ee60>, noverlap=0, pad_to=None, sides='default', scale_by_freq=None)[source]

The coherence between x and y. Coherence is the normalized cross spectral density:

\[C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}\]
Parameters:
x, y

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. This can be different from NFFT, which specifies the number of data points used. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to NFFT

NFFTint

The number of data points used in each block for the FFT. A power 2 is most efficient. The default value is 256. This should NOT be used to get zero padding, or the scaling of the result will be incorrect. Use pad_to for this instead.

detrend{'none', 'mean', 'linear'} or callable, default 'none'

The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the detrend parameter is a vector, in Matplotlib is it a function. The mlab module defines detrend_none, detrend_mean, and detrend_linear, but you can use a custom function as well. You can also use a string to choose one of the functions: 'none' calls detrend_none. 'mean' calls detrend_mean. 'linear' calls detrend_linear.

scale_by_freqbool, optional

Specifies whether the resulting density values should be scaled by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MATLAB compatibility.

noverlapinteger

The number of points of overlap between blocks. The default value is 0 (no overlap).

Returns:
The return value is the tuple (Cxy, f), where f are the
frequencies of the coherence vector. For cohere, scaling the
individual densities by the sampling frequency has no effect,
since the factors cancel out.

See also

psd(), csd()
For information about the methods used to compute \(P_{xy}\), \(P_{xx}\) and \(P_{yy}\).
matplotlib.mlab.complex_spectrum(x, Fs=None, window=None, pad_to=None, sides=None)[source]

Compute the complex-valued frequency spectrum of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.

Parameters:
x1-D array or sequence

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).

Returns:
spectrum1-D array

The values for the complex spectrum (complex valued)

freqs1-D array

The frequencies corresponding to the elements in spectrum

See also

magnitude_spectrum
Returns the absolute value of this function.
angle_spectrum
Returns the angle of this function.
phase_spectrum
Returns the phase (unwrapped angle) of this function.
specgram
Can return the complex spectrum of segments within the signal.
matplotlib.mlab.csd(x, y, NFFT=None, Fs=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None)[source]

Compute the cross-spectral density.

The cross spectral density \(P_{xy}\) by Welch's average periodogram method. The vectors x and y are divided into NFFT length segments. Each segment is detrended by function detrend and windowed by function window. noverlap gives the length of the overlap between segments. The product of the direct FFTs of x and y are averaged over each segment to compute \(P_{xy}\), with a scaling to correct for power loss due to windowing.

If len(x) < NFFT or len(y) < NFFT, they will be zero padded to NFFT.

Parameters:
x, y1-D arrays or sequences

Arrays or sequences containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. This can be different from NFFT, which specifies the number of data points used. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to NFFT

NFFTint

The number of data points used in each block for the FFT. A power 2 is most efficient. The default value is 256. This should NOT be used to get zero padding, or the scaling of the result will be incorrect. Use pad_to for this instead.

detrend{'none', 'mean', 'linear'} or callable, default 'none'

The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the detrend parameter is a vector, in Matplotlib is it a function. The mlab module defines detrend_none, detrend_mean, and detrend_linear, but you can use a custom function as well. You can also use a string to choose one of the functions: 'none' calls detrend_none. 'mean' calls detrend_mean. 'linear' calls detrend_linear.

scale_by_freqbool, optional

Specifies whether the resulting density values should be scaled by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MATLAB compatibility.

noverlapinteger

The number of points of overlap between segments. The default value is 0 (no overlap).

Returns:
Pxy1-D array

The values for the cross spectrum P_{xy} before scaling (real valued)

freqs1-D array

The frequencies corresponding to the elements in Pxy

See also

psd
equivalent to setting y = x.

References

Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)

matplotlib.mlab.demean(x, axis=0)[source]

[Deprecated] Return x minus its mean along the specified axis.

Parameters:
xarray or sequence

Array or sequence containing the data Can have any dimensionality

axisinteger

The axis along which to take the mean. See numpy.mean for a description of this argument.

See also

detrend_mean
Same as demean except for the default axis.

Notes

Deprecated since version 3.1.

matplotlib.mlab.detrend(x, key=None, axis=None)[source]

Return x with its trend removed.

Parameters:
xarray or sequence

Array or sequence containing the data.

key{'default', 'constant', 'mean', 'linear', 'none'} or function

Specifies the detrend algorithm to use. 'default' is 'mean', which is the same as detrend_mean. 'constant' is the same. 'linear' is the same as detrend_linear. 'none' is the same as detrend_none. The default is 'mean'. See the corresponding functions for more details regarding the algorithms. Can also be a function that carries out the detrend operation.

axisinteger

The axis along which to do the detrending.

See also

detrend_mean
Implementation of the 'mean' algorithm.
detrend_linear
Implementation of the 'linear' algorithm.
detrend_none
Implementation of the 'none' algorithm.
matplotlib.mlab.detrend_linear(y)[source]

Return x minus best fit line; 'linear' detrending.

Parameters:
y0-D or 1-D array or sequence

Array or sequence containing the data

axisinteger

The axis along which to take the mean. See numpy.mean for a description of this argument.

See also

detrend_mean
Another detrend algorithm.
detrend_none
Another detrend algorithm.
detrend
A wrapper around all the detrend algorithms.
matplotlib.mlab.detrend_mean(x, axis=None)[source]

Return x minus the mean(x).

Parameters:
xarray or sequence

Array or sequence containing the data Can have any dimensionality

axisinteger

The axis along which to take the mean. See numpy.mean for a description of this argument.

See also

detrend_linear
Another detrend algorithm.
detrend_none
Another detrend algorithm.
detrend
A wrapper around all the detrend algorithms.
matplotlib.mlab.detrend_none(x, axis=None)[source]

Return x: no detrending.

Parameters:
xany object

An object containing the data

axisinteger

This parameter is ignored. It is included for compatibility with detrend_mean

See also

detrend_mean
Another detrend algorithm.
detrend_linear
Another detrend algorithm.
detrend
A wrapper around all the detrend algorithms.
matplotlib.mlab.magnitude_spectrum(x, Fs=None, window=None, pad_to=None, sides=None)[source]

Compute the magnitude (absolute value) of the frequency spectrum of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.

Parameters:
x1-D array or sequence

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).

Returns:
spectrum1-D array

The values for the magnitude spectrum (real valued)

freqs1-D array

The frequencies corresponding to the elements in spectrum

See also

psd
Returns the power spectral density.
complex_spectrum
This function returns the absolute value of complex_spectrum.
angle_spectrum
Returns the angles of the corresponding frequencies.
phase_spectrum
Returns the phase (unwrapped angle) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
matplotlib.mlab.phase_spectrum(x, Fs=None, window=None, pad_to=None, sides=None)[source]

Compute the phase of the frequency spectrum (unwrapped angle spectrum) of x. Data is padded to a length of pad_to and the windowing function window is applied to the signal.

Parameters:
x1-D array or sequence

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to the length of the input signal (i.e. no padding).

Returns:
spectrum1-D array

The values for the phase spectrum in radians (real valued)

freqs1-D array

The frequencies corresponding to the elements in spectrum

See also

complex_spectrum
This function returns the phase value of complex_spectrum.
magnitude_spectrum
Returns the magnitudes of the corresponding frequencies.
angle_spectrum
Returns the angle (wrapped phase) of the corresponding frequencies.
specgram
Can return the complex spectrum of segments within the signal.
matplotlib.mlab.psd(x, NFFT=None, Fs=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None)[source]

Compute the power spectral density.

The power spectral density \(P_{xx}\) by Welch's average periodogram method. The vector x is divided into NFFT length segments. Each segment is detrended by function detrend and windowed by function window. noverlap gives the length of the overlap between segments. The \(|\mathrm{fft}(i)|^2\) of each segment \(i\) are averaged to compute \(P_{xx}\).

If len(x) < NFFT, it will be zero padded to NFFT.

Parameters:
x1-D array or sequence

Array or sequence containing the data

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. This can be different from NFFT, which specifies the number of data points used. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to NFFT

NFFTint

The number of data points used in each block for the FFT. A power 2 is most efficient. The default value is 256. This should NOT be used to get zero padding, or the scaling of the result will be incorrect. Use pad_to for this instead.

detrend{'none', 'mean', 'linear'} or callable, default 'none'

The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the detrend parameter is a vector, in Matplotlib is it a function. The mlab module defines detrend_none, detrend_mean, and detrend_linear, but you can use a custom function as well. You can also use a string to choose one of the functions: 'none' calls detrend_none. 'mean' calls detrend_mean. 'linear' calls detrend_linear.

scale_by_freqbool, optional

Specifies whether the resulting density values should be scaled by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MATLAB compatibility.

noverlapinteger

The number of points of overlap between segments. The default value is 0 (no overlap).

Returns:
Pxx1-D array

The values for the power spectrum P_{xx} (real valued)

freqs1-D array

The frequencies corresponding to the elements in Pxx

See also

specgram
specgram differs in the default overlap; in not returning the mean of the segment periodograms; and in returning the times of the segments.
magnitude_spectrum
returns the magnitude spectrum.
csd
returns the spectral density between two signals.

References

Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John Wiley & Sons (1986)

matplotlib.mlab.specgram(x, NFFT=None, Fs=None, detrend=None, window=None, noverlap=None, pad_to=None, sides=None, scale_by_freq=None, mode=None)[source]

Compute a spectrogram.

Compute and plot a spectrogram of data in x. Data are split into NFFT length segments and the spectrum of each section is computed. The windowing function window is applied to each segment, and the amount of overlap of each segment is specified with noverlap.

Parameters:
xarray-like

1-D array or sequence.

Fsscalar

The sampling frequency (samples per time unit). It is used to calculate the Fourier frequencies, freqs, in cycles per time unit. The default value is 2.

windowcallable or ndarray

A function or a vector of length NFFT. To create window vectors see window_hanning, window_none, numpy.blackman, numpy.hamming, numpy.bartlett, scipy.signal, scipy.signal.get_window, etc. The default is window_hanning. If a function is passed as the argument, it must take a data segment as an argument and return the windowed version of the segment.

sides{'default', 'onesided', 'twosided'}

Specifies which sides of the spectrum to return. Default gives the default behavior, which returns one-sided for real data and both for complex data. 'onesided' forces the return of a one-sided spectrum, while 'twosided' forces two-sided.

pad_toint

The number of points to which the data segment is padded when performing the FFT. This can be different from NFFT, which specifies the number of data points used. While not increasing the actual resolution of the spectrum (the minimum distance between resolvable peaks), this can give more points in the plot, allowing for more detail. This corresponds to the n parameter in the call to fft(). The default is None, which sets pad_to equal to NFFT

NFFTint

The number of data points used in each block for the FFT. A power 2 is most efficient. The default value is 256. This should NOT be used to get zero padding, or the scaling of the result will be incorrect. Use pad_to for this instead.

detrend{'none', 'mean', 'linear'} or callable, default 'none'

The function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in MATLAB, where the detrend parameter is a vector, in Matplotlib is it a function. The mlab module defines detrend_none, detrend_mean, and detrend_linear, but you can use a custom function as well. You can also use a string to choose one of the functions: 'none' calls detrend_none. 'mean' calls detrend_mean. 'linear' calls detrend_linear.

scale_by_freqbool, optional

Specifies whether the resulting density values should be scaled by the scaling frequency, which gives density in units of Hz^-1. This allows for integration over the returned frequency values. The default is True for MATLAB compatibility.

noverlapint, optional

The number of points of overlap between blocks. The default value is 128.

modestr, optional
What sort of spectrum to use, default is 'psd'.
'psd'

Returns the power spectral density.

'complex'

Returns the complex-valued frequency spectrum.

'magnitude'

Returns the magnitude spectrum.

'angle'

Returns the phase spectrum without unwrapping.

'phase'

Returns the phase spectrum with unwrapping.

Returns:
spectrumarray-like

2-D array, columns are the periodograms of successive segments.

freqsarray-like

1-D array, frequencies corresponding to the rows in spectrum.

tarray-like

1-D array, the times corresponding to midpoints of segments (i.e the columns in spectrum).

See also

psd
differs in the overlap and in the return values.
complex_spectrum
similar, but with complex valued frequencies.
magnitude_spectrum
similar single segment when mode is 'magnitude'.
angle_spectrum
similar to single segment when mode is 'angle'.
phase_spectrum
similar to single segment when mode is 'phase'.

Notes

detrend and scale_by_freq only apply when mode is set to 'psd'.

matplotlib.mlab.stride_repeat(x, n, axis=0)[source]

[Deprecated] Repeat the values in an array in a memory-efficient manner. Array x is stacked vertically n times.

Warning

It is not safe to write to the output array. Multiple elements may point to the same piece of memory, so modifying one value may change others.

Parameters:
x1D array or sequence

Array or sequence containing the data.

ninteger

The number of time to repeat the array.

axisinteger

The axis along which the data will run.

Notes

Deprecated since version 3.2.

References

stackoverflow: Repeat NumPy array without replicating data?

matplotlib.mlab.stride_windows(x, n, noverlap=None, axis=0)[source]

Get all windows of x with length n as a single array, using strides to avoid data duplication.

Warning

It is not safe to write to the output array. Multiple elements may point to the same piece of memory, so modifying one value may change others.

Parameters:
x1D array or sequence

Array or sequence containing the data.

ninteger

The number of data points in each window.

noverlapinteger

The overlap between adjacent windows. Default is 0 (no overlap)

axisinteger

The axis along which the windows will run.

References

stackoverflow: Rolling window for 1D arrays in Numpy? stackoverflow: Using strides for an efficient moving average filter

matplotlib.mlab.window_hanning(x)[source]

Return x times the hanning window of len(x).

See also

window_none
Another window algorithm.
matplotlib.mlab.window_none(x)[source]

No window function; simply return x.

See also

window_hanning
Another window algorithm.