1

I have four images, and I would like to visualize them without spaces (I am trying to project a map).

But I do not understand why 'wspace' is not working:

fig, axs = plt.subplots(2, 2, gridspec_kw={'hspace': 0, 'wspace': 0}) #, tight_layout = {'pad': 0})
(ax1, ax2), (ax3, ax4) = axs
ax1.imshow(map1)
ax1.axis('off')
ax2.imshow(map2)
ax2.axis('off')
ax3.imshow(map3)
ax3.axis('off')
ax4.imshow(map4)
ax4.axis('off')


# Hide x labels and tick labels for all but bottom plot.
for ax in axs.flat:
    ax.label_outer()
    
plt.savefig('map4x4.png', dpi=150)

and what I visualize in the plot box of spyder is:

enter image description here

In which I clearly could see that the 'hspace=0' is working but not the 'wspace=0'. I must write 'wscpace=-0.6' to have non spaces between the images, but this is not a good code.

Also, when I see the image which has been saved, I can see even small white line between the vertical images:

enter image description here

Any ideas of what is happening? Why I have this big space between horizontal images? How could I fix it?

Mr. T
  • 11,960
  • 10
  • 32
  • 54
Cara_CH
  • 11
  • 1
  • 1
    I assume this is related to [this problem](https://stackoverflow.com/a/36049914/8881141) because you probably set somewhere `aspect='equal'` to prevent the map images to be distorted. – Mr. T May 29 '21 at 08:57
  • See also [How to remove the space between subplots?](https://stackoverflow.com/questions/41071947/how-to-remove-the-space-between-subplots-in-matplotlib-pyplot) – JohanC May 29 '21 at 13:41

0 Answers0