The following code
import numpy as np
import matplotlib.pyplot as plt
nrows, ncols = 5, 11
fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(ncols, nrows))
fig.tight_layout()
W, H = 73, 73
for r in range(nrows):
axes[r,0].imshow(np.random.rand(W, H), cmap="gray", interpolation="none")
axes[r,0].set_axis_off()
axes[r,0].set_aspect('equal')
for c in range(ncols-1):
for r in range(nrows):
axes[r,c+1].imshow(np.random.rand(W, H), cmap="viridis", interpolation="none")
axes[r,c+1].set_axis_off()
axes[r,c+1].set_aspect('equal')
plt.subplots_adjust(wspace=0.1, hspace=0.1)
plt.savefig("test_plot.png", dpi=300, bbox_inches="tight")
plt.close()
produces the following output:
The black background is for reference only. The white outer border is larger on the left and bottom than on the right and top. I would like to know how I can adjust the plot such that the distance to the edge is the same on all sides.