I used matplotlib.pyplot to plot a list of images [img1, img2, ..., img100]
, in order to draw them in order, I used plt.subplots
to divide the figure area.
This is my code:
def show_images(imgs, num_rows, num_cols, titles=None, scale=2, imgText=None, save=False, img_dir=None):
figsize = (num_cols * scale, num_rows * (scale))
_, axes = plt.subplots(num_rows, num_cols, figsize=figsize,frameon =False)
axes = axes.flatten()
for i, (ax, img) in enumerate(zip(axes, imgs)):
img=np.transpose(img * 255, (1, 2, 0))
ax.imshow(img,cmap='gray')
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
if not titles is None:
ax.set_title(titles[i])
plt.show()
return axes
The resulting figure is here. But I wasn't able to put a main title on the plt.subplots figure. How can I achive that so that it looks like this?