Я пытаюсь визуализировать спектрограмму с помощью Matplotlib.
temp = total_slices[subject_num, trail_num, :, :]
spectrum = np.fft.fft(temp, axis=0)[:M // 2 + 1:-1]
spectrum = np.abs(spectrum)
print(spectrum.shape)
# recording length:
L = remaining_samples_from_rec[subject_num, trail_num, :].shape[0]
# rate is the sampling frequency or sampling_rate
rate = sampling_rate
S = np.abs(spectrum)
S = 10 * np.log10(S / np.max(S))
print(S.shape, type(S))
fig, ax = plt.subplots(figsize=(4.8, 2.4))
ax.set_ylabel('Frequency [kHz]')
ax.set_xlabel('Time [ms]');
dir_path = 'PaperFigures/steady/' + col + '/' + vowel
if not os.path.exists(dir_path):
os.makedirs(dir_path)
xticks = np.linspace(start=0, stop=spectrum.shape[1], num=10, dtype=np.int32)
xticks_labels = [str(x) for x in np.linspace(start=0, stop=300, num=10, dtype=np.int32)]
ax.set_xticks(xticks)
ax.set_xticklabels(xticks_labels, rotation=45)
ax.imshow(S, origin='lower', cmap='viridis')
fig.savefig(dir_path + '/subject_{}_trail_{}.png'.format(subject_num, trail_num))
Следовательно, я получаю:
Мне интересно, как я могу сделать ось Y шире. Я попытался fig, ax = plt.subplots(figsize=(4.8, 20.4))
, но это не сработало .. Я попытался установить yticks и yticks_labels, и это тоже не сработало.
Любая помощь очень ценится !!
![enter image description here](https://i.stack.imgur.com/jejZb.png)