A
A
aab1372019-01-05 10:04:45
Python
aab137, 2019-01-05 10:04:45

Spectrogram audio python matplotlib: how to change color and add intensity scale?

There is a code

import matplotlib.pyplot as plt
import scipy.io.wavfile
sample_rate, X = scipy.io.wavfile.read('TEST2.wav')
print(sample_rate, X.shape)
plt.specgram(X[:, 0], NFFT=256, Fs=sample_rate)
plt.show()

which gives
jDAx7b.png
I would like to get something like
i?id=4e3a5236d7e03c05146d6bc1f7437f6c-l&
, i.e., more colorful and with an intensity
scale

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aab137, 2019-01-06
@aab137

Hooray!
Thanks Andy_U !

import matplotlib.pyplot as plt
import scipy.io.wavfile
sample_rate, X = scipy.io.wavfile.read('TEST2.wav')
print(sample_rate, X.shape)
plt.xlabel('Время, c', fontsize='x-large')
plt.ylabel('Частота, Гц', fontsize='x-large')
plt.title('Спектрограмма для колбы')
cmap = plt.get_cmap('magma')
plt.specgram(X[:, 0], NFFT=256, pad_to=256, mode='magnitude', Fs=sample_rate, cmap=cmap)
plt.colorbar()
plt.show()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question