When I am computing a FFT with scipy.fftpack on a signal and plot it afterwards, I get a constant horizontal line (and a vertical line on my data) Can anyone explain why these lines occur and maybe present a solution to plot the spectrum without the lines?
Let's take a look at a simple signal. Sinusoidal wave with a frequenz of 12 Hertz. In this example you can see the horizontal line at about y = 2.1
.
import numpy as np
import matplotlib.pyplot as plt
import scipy.fftpack
# test signal
omega = 2 * np.pi * 12
t = np.linspace(-15, 15, 1000)
ampl = np.sin(omega * t)
# compute fft, fft frequences
fft = abs(scipy.fft(amp))
freq = scipy.fftpack.fftfreq(fft.size, t[1] - t[0])
# plot
plt.plot(freq, fft)
And here's the fft plot from my experimental signal (zoomed in). You can see the horizontal line (y =~ 0.0015
) and also a vertical line (at x = 0
).
I cannot find any data in my arrays according to these lines. Why do these lines occur?