I'm trying to plot a signal and the spectrogram of the signal with matplotlib, but... i get the spectrogram only for the first value (samples) of my signal (like 60 of the 30000...).
It's a very long file, that's why I would like to plot only the first 30000 sample.
here is the code :
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Data=pd.read_csv('MySignal.txt',
skiprows=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],
header=0)
print(Data.head())
DataI=Data['Sig'].tolist()
print(len(Data.index))
DataI=DataI[0:30000]
NFFT = 200 # the length of the windowing segments
Fs = 500 # the sampling rate
# plot signal and spectrogram
t=range(len(DataI))
ax1 = plt.subplot(211)
plt.plot(t, DataI)
plt.subplot(212, sharex=ax1)
Pxx, freqs, bins, im = plt.specgram(DataI, NFFT=NFFT,
Fs=Fs,noverlap=100, cmap=plt.cm.gist_heat)
plt.show()
I don't understand well how plt.specgram work, so i don't understand where is the problem...
Thanks a lot !
