我使用matplotlib.pyplot绘制了一个图像列表,[img1, img2, ..., img100]
,为了按照顺序绘制它们,我使用plt.subplots
来划分图形区域。这是我的密码:
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
发布于 2022-05-17 13:36:06
你试过把情节本身编出来吗?
plt.title("Your title here")
我记得,如果你在调用子图之前就这么做了,它就会命名为整件事。
https://stackoverflow.com/questions/72274987
复制相似问题