我想从一个数据帧中画出一堆图像。但我现在正为两个问题而挣扎。这是我的剧本中应该绘制图片的部分。
nrows = len(df.index)
ncols = len(df.columns)
plotindex = 1
for row in df.index:
for col in df.columns:
plt.subplot(nrows, ncols, plotindex)
x = Image.open(df[row][col])
x = x.resize((500, 500), Image.ANTIALIAS)
plt.imshow(x)
plt.axis('off')
plotindex += 1
plt.show()发布于 2020-09-28 18:22:28
让我们试试:
nrows, ncols = df.shape
fig, axes = plt.subplots(nrows, ncols)
for row in range(nrows):
for col in range(ncols):
x = Image.open(df.iloc[row, col])
x = x.resize((500,500), Image.ANTIALIAS)
axes[row,col].imshow(x)
plt.show()https://stackoverflow.com/questions/64107486
复制相似问题