# Why are low frequency peaks not sharp in scipy fft?

I am using numpy/scipy to plot graphs of sine waves. frequencies at 15 Hz or higher give nice, sharp peaks, but at lower frequencies, the peaks are smeared and the actual peak frequency can't be seen in the graph. Why is that happening and how do i stop that?

    import numpy as np
import matplotlib.pyplot as plt

tmin = 0
tmax = 0.5
N = 10000 #No. of samples
t = np.linspace(tmin, tmax, N)
T = t[1]-t[0] #sampling interval
fs = 1/T #sampling frequency
print(fs)
# x1 = np.sin(2*np.pi*5*t) + 0.8*np.sin(2*np.pi*10*t)
x1 = np.sin(2*np.pi*20*t) + np.sin(2*np.pi*30*t) + np.sin(2*np.pi*5*t) + np.sin(2*np.pi*3*t)
x2 = x1 + np.sin(2*np.pi*50*t) + 0.8*np.sin(2*np.pi*100*t)
x2_fft = fft(x2)
plt.plot(np.abs(x2_fft))
plt.title(r'fft of $$x_2(t)$$')
plt.show()

xf = np.linspace(0, fs/2.0, N//2) #Create frequency axis
plt.plot(xf, 2.0/N * np.abs(x2_fft[0:N//2])) #plot only +ve frequencies
plt.xlim([0, 120])
plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplitude')
plt.title(r'fft of $$x_2(t)$$')
plt.grid(True)
plt.show()

• They seem to get sharper if the interval is increased. – Azhar Mehmood Sep 16 '19 at 20:50
• How many periods of a function must a window have before it becomes clear? – Azhar Mehmood Sep 16 '19 at 20:51
• Define "clear" and "sharp" as per your requirements. – hotpaw2 Sep 17 '19 at 14:59