Plots multiple images in one graph

Or a kind of gallery. Let’s first get a list of images.

import os
from pyensae.datasource import download_data
zipname = "dog-cat-pixabay.zip"
if not os.path.exists("images"):
    os.mkdir("images")
res = download_data(zipname, whereTo="images")
print(res)

Out:

['images/cat-1151519__480.jpg', 'images/cat-1192026__480.jpg', 'images/cat-1508613__480.jpg', 'images/cat-188088__480.jpg', 'images/cat-2083492__480.jpg', 'images/cat-2603300__480.jpg', 'images/cat-2882170__480.jpg', 'images/cat-2917592__480.jpg', 'images/cat-2919036__480.jpg', 'images/cat-2922832__480.jpg', 'images/cat-2942887__480.jpg', 'images/cat-2946028__480.jpg', 'images/cat-2947188__480.jpg', 'images/dachshund-2035700__480.jpg', 'images/dog-1765910__480.jpg', 'images/dog-2365014__480.jpg', 'images/dog-2684073__480.jpg', 'images/dog-2687433__480.jpg', 'images/dog-2687502__480.jpg', 'images/dog-2819614__480.jpg', 'images/dog-2819616__480.jpg', 'images/dog-2863719__480.jpg', 'images/fun-2213606__480.jpg', 'images/happy-1845090__480.jpg', 'images/hot-dog-2361133__480.jpg', 'images/kitty-2948404__480.jpg', 'images/lion-2915164__480.jpg', 'images/schafer-dog-2669660__480.jpg', 'images/shotlanskogo-2934720__480.jpg', 'images/sun-2858214__480.jpg', 'images/wolf-2865653__480.jpg']

Let’s take the first ten images.

imgs = res[:10]

And the gallery.

from mlinsights.plotting import plot_gallery_images
txts = ["img%d" % i for i in range(len(imgs))]
plot_gallery_images(imgs, txts)
../_images/sphx_glr_plot_gallery_001.png

Total running time of the script: ( 0 minutes 0.802 seconds)

Gallery generated by Sphinx-Gallery