Reduce the gap between rows when using matplotlib subplot?

后端 未结 3 1747
-上瘾入骨i
-上瘾入骨i 2021-01-21 15:11

My subplot results

My code

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

for i in range(cols):
    step          


        
3条回答
  •  迷失自我
    2021-01-21 15:56

    You have used figsize=[24,24] to make it a square image. subplots_adjust then makes each ax[i,j] to stick to the adjacent one. But ax.imshow() does not fill each ax. In your sample above, if the vertical size of the image were larger, it would have filled the area alloted to that axes, but by distorting the image. If you want to try that out, use the command ax[0,i].imshow(a[ind,:,:],cmap='gray', aspect='auto'): the aspect='auto' part will stretch your images to fill the axes. If you want the image aspect ratio to not be distorted, then you have to edit your figsize accordingly.

提交回复
热议问题