So, I have been analyzing audio data. I used the librosa package and used its .stft() function to calculate the Fourier transform of my audio data. I did the following-

aud_ft= np.abs(librosa.stft(aud, n_fft = n_fft, hop_length = hop_length,win_length=win_length)) 

The shape of the aud_ft is (1025,1309). The plot represents frequency on the y-axis and time on the x-axis and also represents the power/amplitude of each frequency at each time sample using color.

My doubt is how does a 2d array stores frequency as well as power values?

In addition to that, I noticed some weird outputs of the plot() function. enter image description here


Why does the plot remain the same for both the cases, how do I explain this?

Any help is highly appreciated. Thank you in advance.

  • $\begingroup$ Stackoverflow could be a better venue to ask this. $\endgroup$ Jun 13, 2022 at 21:30
  • $\begingroup$ Okay, thanks for the info. $\endgroup$
    – dhananjaya
    Jun 14, 2022 at 8:51

1 Answer 1


A spectrogram is a multi-variate time-series. When using matplotlib plot() to plot it, you just get each independent time-frame or frequency-band, which throws away the time/frequency relation in the signal. Instead plot the 2d structure as a heatmap. This is easiest done using using librosa.display.specshow.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.