user3734366 - 1 year ago 144

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

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

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)`

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**