引言
论文中有时会用到介绍数据集,每类图像并排放置的显示方式,所以可以自己定制这种类型很有必要(如下图样式)
相关代码
# -*- coding:utf-8 -*-
from pathlib import Path
import random
from matplotlib import pyplot as plt
from PIL import Image
# 读取图像到列表中
image_path = Path(r'make_figure\fmd')
all_selected_images = []
selected_images = []
for one_category in image_path.iterdir():
if one_category.is_dir():
selected_images = list(one_category.iterdir())
random.shuffle(selected_images)
selected_images = selected_images[:10]
all_selected_images.extend(selected_images)
# 绘制多个子图
plt.figure()
for i in range(1, 101):
im = Image.open(str(all_selected_images[i-1]))
im = im.resize((512, 384))
ax = plt.subplot(10, 10, i)