Got an extra line on python plot
<p>i'm using pyplot to show the FFT of the signal 'a', here the code:</p>

<pre><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()
</code></pre>

<p>and i get this figure
<a href="http://i.stack.imgur.com/21CFm.png" rel="nofollow"><img src="http://i.stack.imgur.com/21CFm.png" alt="enter image description here"></a></p>

<p>There is a line from the begin to the end of the signal in the frequency domain. How i can remove this line? AM I doing something wrong with pyplot?</p>

<p>Have a look at <code>plt.plot(numpy.fft.fftfreq(x.shape[-1])</code>: the first and last points are the same, hence the graph "makes a loop"</p>

<p>You can do <code>plt.plot(sorted(numpy.fft.fftfreq(x.shape[-1])),myFFT)</code> or <code>plt.plot(myFFT)</code></p>

python numpy matplotlib fft