结束数字显示与 imshow

Closing figure show vs. imshow

一般情况下,我使用如下图的闭合模式来防止the error

%matplotlib inline

plt.figure()
// plot here what necessary
plt.show()
// figure is displayed inline
plt.close()

替换show with imshow,在for in循环中只显示最后一张图。

如何使用 imshow 在循环中内联绘制,确保正确关闭数字?

基于

for x in y:
    plt.figure()
    plt.imshow(...)
    plt.show()
    plt.close()