I had obtained spectrogram using the following line of code
powerSpectrum, freqenciesFound, time, imageAxis = plt.specgram(data,NFFT=nfft, Fs=Fs)