删除 python 中图像子图中的空白并保存

remove white spaces in images subplot in python and save it

我想使用以下代码在 python3 中创建频谱图的子图。 我的问题是我在地块和

之间有空格
import matplotlib
matplotlib.use('Agg')

import matplotlib.pyplot as plt    

j=0
plt.clf()

f, axarr= plt.subplots(4,5, gridspec_kw = {'wspace':0, 'hspace':0})
f.tight_layout()

for i, ax in enumerate(f.axes):
    j=j+1
    im = ax.imshow(syllable_1.transpose(), vmin=0, vmax=syllable_1.max(), 
    cmap='pink_r')

    plt.xticks([], [])

    #ax[j].autoscale_view('tight')

    #ax.set_xticklabels([])

    #ax.set_yticklabels([])


#plt.subplots_adjust(left=0.1, right=0.85, top=0.85, bottom=0.1)
plt.subplots_adjust(wspace=0, hspace=0)

plt.savefig("myfig9.png", bbox_inches='tight')

结果如下:

你能给我一些解决方案吗?

提前致谢

为了不让你知道,我在我的剧情代码中添加了aspect='auto',它就解决了。我使用了以下 link。看来我没有用好的关键字进行搜索。谢谢