![](/img/trans.png)
[英]How can I make the FigureCanvas fill the entire Figure in a matplotlib widget embedded in a pyqt GUI?
[英]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.