解决方法:
参见:http://matplotlib.sourceforge.net/faq/howto_faq.html#howto-webapp的Matplotlib in a web application server节
http://matplotlib.sourceforge.net/faq/usage_faq.html#what-is-a-backend讲述了backend是什么。
There are two types of backends: user interface backends (for use in pygtk, wxpython, tkinter, qt, macosx, or fltk; also referred to as “interactive backends”) and hardcopy backends to make image files (PNG, SVG, PDF, PS; also referred to as “non-interactive backends”)
所以只要选择一些non-interactive backend 就可以在无前端显示的情况下,执行脚本画图表并写入image文件中。
在python文件的起始处添加
import matplotlib
matplotlib.use('Agg')
本文介绍如何在没有前端显示的情况下使用Matplotlib绘制图表并将其保存为图像文件。通过设置非交互式后端(如Agg),可以实现在无显示环境中生成图表。
3373

被折叠的 条评论
为什么被折叠?



