簡體   English   中英

如何使頻譜圖用matplotlib填充整個圖形區域?

[英]How to make specgram fill entire figure area with matplotlib?

我正在使用以下代碼繪制specgram:

fig = plt.figure(figsize=(5.15, 5.15))
fig.clf()
plot = plt.subplot(111)
plt.specgram(data, NFFT = 256, Fs = 120000)
plot.grid(False, which="major")
plot.set_xlabel(r'\textit{Time (s)}', labelpad=6)
plot.set_ylabel(r'\textit{{Frequency (Hz)}}', labelpad=6)
plt.colorbar()
fig.savefig('specgram.pdf', bbox_inches='tight')
plt.close()

但是,該頻譜圖不會填充整個圖形區域,如下所示:

在此處輸入圖片說明

我可能做錯了什么?

我認為您需要將set_xlim設置為數據的最大值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM