import numpy as nupy import matplotlib.pyplot as plt f1 = 1 # starting frequency in Hz f2 = 5 # final frequency in Hz np = 1000. # number of points dt = 0.01 # time step idx = nupy.arange(np)/(np - 1.) ts = idx*np*dt freqs = (f2 - f1)*idx + f1 phi = nupy.cumsum(freqs*dt) sig = nupy.sin(2.*nupy.pi*phi) sigfft = nupy.fft.fft(sig) amp = (nupy.abs(2*sigfft/np))[0:np/2+1] pha = (nupy.angle(sigfft))[0:np/2+1] freq = nupy.arange(np/2 + 1)/(np*dt) plt.figure() plt.subplot(2, 1, 1) plt.plot(ts, sig) plt.xlabel("Time [s]") plt.ylabel("Amplitude") plt.subplot(2, 1, 2) plt.plot(freq, amp) plt.xlabel("Frequency [Hz]") plt.ylabel("Amplitude") plt.show()