简体   繁体   English

Spyder控制台关闭交互式matplotlib绘图

[英]Spyder console turn off interactive matplotlib plotting

I'm doing some plotting using matplotlib in the Spyder GUI. 我在Spyder GUI中使用matplotlib进行一些绘图。 I just want these figures to be made quietly in the background and save to a file path. 我只是希望这些数字在后台安静地制作并保存到文件路径中。 I'm running my scripts from the console and while the figures get made and saved fine, I can't stop them all popping up in their own little windows (there are about 240 graphs so clearly this is causing memory issues). 我正在从控制台运行我的脚本,当数字被制作并保存得很好时,我无法阻止它们全部弹出自己的小窗口(大约有240个图表,因此很明显这会导致内存问题)。

I have scattered the command plt.ioff() generously throughout the script but it doesn't seem to help 我在整个脚本中慷慨地散布了命令plt.ioff(),但它似乎没有帮助

Any ideas? 有任何想法吗? Cheers 干杯

Figures should not be popping up if you use a non-interactive backend. 如果您使用非交互式后端,则不应弹出数字。 Put this at the very beginning of the script: 把它放在脚本的最开头:

import matplotlib as mpl
mpl.use('Agg')

You might run into memory issues anyway if you create many figures without closing them. 如果你创建了许多数字而没有关闭它们,你可能会遇到内存问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM