Show Images in Grid Using Matplotlib

Aug 28, 2020
from IPython.display import Imageimport pathlibfrom pathlib import Path import matplotlib.pyplot as pltoutput_dir = pathlib.Path("/content/output/")images = list(output_dir.glob('*.jpg'))# set the canvas size in inchesplt.figure(figsize=(10,10))for i, img_path in enumerate(images):  img_path = str(img_path)  # the number of images in the grid is 3*3 (9)  plt.subplot(3,3,i+1)      img = plt.imread(img_path)  plt.imshow(img)  plt.title(Path(img_path).name)  plt.axis("off")plt.show()plt.close()

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.