如何关闭所有pyplot窗口(包括先前脚本执行中的窗口)? [英] How do I close all pyplot windows (including ones from previous script executions)?

查看:86
本文介绍了如何关闭所有pyplot窗口(包括先前脚本执行中的窗口)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一些使用pyplot绘制一些图形的python代码.每次我运行脚本时都会创建新的绘图窗口,我必须手动关闭这些窗口.如何在脚本开始时关闭所有打开的 pyplot 窗口?IE.关闭脚本先前执行期间打开的窗口?

So I have some python code that plots a few graphs using pyplot. Every time I run the script new plot windows are created that I have to close manually. How do I close all open pyplot windows at the start of the script? Ie. closing windows that were opened during previous executions of the script?

在MatLab中,只需使用 closeall 即可完成此操作.

In MatLab this can be done simply by using closeall.

推荐答案

要关闭脚本中所有打开的图形,可以调用

To close all open figures from a script, you can call

plt.close('all')

或者您可以终止关联的Python进程.

or you can terminate the associated Python process.

这篇关于如何关闭所有pyplot窗口(包括先前脚本执行中的窗口)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆