python - Ploting a spectrogram of a pure sinus with matplotlib -


i'm trying spectogram plot of pure sine function. want show plot of fft of whole signal. i'm expecting peaks on same frequency since dealing same signal stationary in time.

code

samplingfrequency = 32. frequency = 4                           #frequency of sinus wave t = arange(0,20,1/samplingfrequency)    #time intervals period 1/sampling frequency y = cos(2*pi*frequency*t)  y = fft.fft(y)                          #standard fft on whole signal frequencyaxis = fft.fftfreq(len(y),1/samplingfrequency )          #adjusting x axis   #plotting fig, (ax1,ax2) = plt.subplots(nrows=2, ncols=1) ax1.specgram(y, fs = samplingfrequency) ax2.stem(frequencyaxis,y,linefmt='r--', markerfmt='ro') 

plot enter image description here

the fft of whole signal expected peak on 4. spectogram plots line on 12. ideas on error is?

update using following versions:

  • matplotlib '1.1.1'
  • numpy '1.6.2'
  • python 2.7.3

on python 2.7.5 numpy 1.7.1 , matplotlib 1.2.1 code works expected. try updating both numpy , matplotlib installations recent versions.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -