减少使用matplotlib子图时行之间的间隔? [英] Reduce the gap between rows when using matplotlib subplot?

查看:58
本文介绍了减少使用matplotlib子图时行之间的间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的子图结果

我的代码

fig,ax = plt.subplots(rows,cols, figsize = [24,24])
plt.subplots_adjust(hspace=0, wspace=0)

for i in range(cols):
    step = 6
    ind = i*step
    ax[0,i].imshow(a[ind,:,:],cmap='gray')
    ax[0,i].axis('off')

    ax[1,i].imshow(b[ind,:,:],cmap='gray')
    ax[1,i].axis('off')

    ax[2,i].imshow(c[ind,:,:],cmap='gray')
    ax[2,i].axis('off')

然而,似乎 plt.subplots_adjust(hspace=0, wspace=0) 根本不起作用.我注意到它强制图形具有相等的 x 和 y 大小,你能帮我纠正这个吗?

However, it seems like plt.subplots_adjust(hspace=0, wspace=0) not working at all. I notice that it forces the figure to have equal x and y size, could you help me correct this?

推荐答案

您可以在垂直方向上缩小图形大小,例如

You may either shrink the figure size in vertical direction, e.g.

fig,ax = plt.subplots(rows,cols, figsize = [24,12])

或者你可以保持正方形的大小,但在子图周围放置更多的边距

or you may keep the square figure size but put more margin around the subplots

plt.subplots_adjust(bottom=0.3, top=0.7, hspace=0)

这篇关于减少使用matplotlib子图时行之间的间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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