如何使用 matplotlib 使光谱图填充整个图形区域? [英] How to make specgram fill entire figure area with matplotlib?

查看:38
本文介绍了如何使用 matplotlib 使光谱图填充整个图形区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码绘制频谱图:

I am plotting specgram usign the following code:

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()

但是,该频谱图并未填充整个图形区域,如下所示:

But the specgram does not fill the entire figure area as shown below:

我可能做错了什么?

推荐答案

我认为您需要set_xlim 到您的数据的最大值.

I think you need to set_xlim to the maximum value of your data.

这篇关于如何使用 matplotlib 使光谱图填充整个图形区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆