From e661d261d67dbf7619b74bd2a36a9a715203156e Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sat, 11 Nov 2017 20:50:16 -0800 Subject: [PATCH] FIX: Detrending before windowing _spectral_helper --- lib/matplotlib/mlab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index 194420816175..3664e869814e 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -720,8 +720,8 @@ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None, if not same_data: # if same_data is False, mode must be 'psd' resultY = stride_windows(y, NFFT, noverlap) - resultY = apply_window(resultY, window, axis=0) resultY = detrend(resultY, detrend_func, axis=0) + resultY = apply_window(resultY, window, axis=0) resultY = np.fft.fft(resultY, n=pad_to, axis=0)[:numFreqs, :] result = np.conj(result) * resultY elif mode == 'psd':