Quantcast
Viewing all articles
Browse latest Browse all 237

Use matplotlib to draw multiple pictures

To draw some sample images in one page, I used one of the most popular python library matplotlib:

import cv2
import matplotlib.pyplot as plt

img = cv2.imread("bird.jpg")
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

rows = 4
columns = 2

fig, ax = plt.subplots(nrows=rows, ncols=columns)
for index in range(columns*rows):
    ax.ravel()[index].imshow(img)
    ax.ravel()[index].set_title("Subplot"+str(index), {'fontsize': 6})
    ax.ravel()[index].set_axis_off()
plt.show()

Then it will jump out a windows like this:

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 237

Trending Articles