【发布时间】:2021-10-27 20:32:27
【问题描述】:
我想为每个子图添加标题,并去掉其中的 x 轴和 y 轴。
fig = plt.figure(figsize=(6,6)) # specifying the overall grid size
for i in range(16):
plt.subplot(4,4,i+1) # the number of images in the grid is 6*6 (16)
img = mpimg.imread(f'../input/cifar10-mu/train_images/{train["filename"][i]}')
plt.imshow(img)
fig.suptitle('Sample Images')
plt.show()
这是上面代码的输出
【问题讨论】:
-
将“plt.subplot(4,4,i+1)”替换为“plt.subplot(4, 4, i + 1, xticks = [], yticks = [], frameon = False )" 应该可以工作。
标签: python matplotlib