In the code below, you want to limit the y-axis from 0 to 1000 for the second plot.
FFT
has an infinite number, so I'm just going to cut it to the top 1000.
import scipy
from matplotlib import pylab
xs = []
rawsignal = []
with open("myfile.txt", 'r') as f:
for line in f:
if line[0] != '#' and len(line) > 0:
xs.append( int( line.split()[0] ) )
rawsignal.append( int( line.split()[1] ) )
h, w = 3, 1
pylab.figure(figsize=(12,9))
pylab.subplots_adjust(hspace=.7)
pylab.subplot(h,w,1)
pylab.title("Signal")
pylab.plot(xs,rawsignal)
pylab.subplot(h,w,2)
pylab.title("FFT")
fft = scipy.fft(rawsignal)
Plot pylab. ((fft abs)) # limited scope of the y-axis here.
pylab.savefig("SIG.png",dpi=200)
pylab.show()
pylab.plot(abs(fft))
after
pylab.ylim([0,1000])
Please add.
© 2024 OneMinuteCode. All rights reserved.