Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我能';t关闭jupyter笔记本中matplotlib.pyplot的fig_Python_Matplotlib_Jupyter Notebook - Fatal编程技术网

Python 我能';t关闭jupyter笔记本中matplotlib.pyplot的fig

Python 我能';t关闭jupyter笔记本中matplotlib.pyplot的fig,python,matplotlib,jupyter-notebook,Python,Matplotlib,Jupyter Notebook,windows python 3.7.3 matplotlib 3.0.3 for raw_name in img_list: img1 = np.asarray(Image.open(os.path.join(ROOT, raw_name))) img2 = np.asarray(Image.open(os.path.join(ROOT, raw_name.replace('.jpg', '.png')))) f, ax

windows python 3.7.3 matplotlib 3.0.3

for raw_name in img_list: 
            img1 = np.asarray(Image.open(os.path.join(ROOT, raw_name)))
            img2 = np.asarray(Image.open(os.path.join(ROOT, raw_name.replace('.jpg', '.png'))))
            f, axarr = plt.subplots(1, 2, dpi=400, frameon=False, gridspec_kw={'width_ratios': [6, 1]})
            plt.ion()
            axarr[0].imshow(img1)
            plt.axis('off')
            axarr[1].imshow(img2)
            plt.axis('off')

            plt.show(block=False)
            plt.close('all')
我想在每个循环中显示图像,并通过在每个循环结束时关闭绘图来刷新输出。但结果只是一张接一张地显示图像。
有人能告诉我如何关闭jupyter笔记本中的绘图吗?

如果您想清除单元格输出,可以使用
清除输出(wait=True)
。从
IPython.display导入
,并在需要清除单元格输出时插入它,例如在plt.close()之后,谢谢它工作!但是为什么plt.close()不起作用呢?plt.close()关闭了与绘图的交互,因此不会在同一个图形中绘制更多的绘图,但该图形仍然可见。