user3734366 - 10 months ago 80

Python Question

i'm using pyplot to show the FFT of the signal 'a', here the code:

`myFFT=numpy.fft.fft(a)`

x=numpy.arange(len(a))

fig2=plt.figure(2)

plt.plot(numpy.fft.fftfreq(x.shape[-1]),myFFT)

fig2.show()

and i get this figure

There is a line from the begin to the end of the signal in the frequency domain. How i can remove this line? i'm doing something wrong with pyplot?

Thank You

Answer Source

Have a look at `plt.plot(numpy.fft.fftfreq(x.shape[-1])`

: the first and last points are the same, hence the graph "makes a loop"

You can do `plt.plot(sorted(numpy.fft.fftfreq(x.shape[-1])),myFFT)`

or `plt.plot(myFFT)`