Why can't I remove vertical whitespace between subplots?

Viewed 80

I am trying to remove the whitespace between subplots. While this works fine for the horizontal whitespace, it doesn't for the vertical. I am using the following code:

    fig_head3, axs_head = plt.subplots(4, 5, figsize=(20, 20))
    fig_head3.suptitle("Overview", fontsize="x-large")
    for i in range(4):
        axs_head[i, 0].imshow(img[i * 5])
        axs_head[i, 0].axis('off')
        axs_head[i, 1].imshow(img[i * 5 + 1])
        axs_head[i, 1].axis('off')
        axs_head[i, 2].imshow(img[i * 5 + 2])
        axs_head[i, 2].axis('off')
        axs_head[i, 3].imshow(img[i * 5 + 3])
        axs_head[i, 3].axis('off')
        axs_head[i, 4].imshow(img[i * 5 + 4])
        axs_head[i, 4].axis('off')
    plt.subplots_adjust(wspace=0, hspace=0)

This results in the following plot:

enter image description here

Does anyone know what goes wrong here? I did some research and read multiple times that plt.subplots_adjust(wspace=0, hspace=0) should work. Thank's a lot!

0 Answers
Related