UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figur

838 ワード

1、質問:Backend TkAgg is interactive backend.Turning interactive mode on.
matplotlibのデフォルトbackendはTkAggであり、FltkAgg、GTK、GTKAgg、GTKCAiro、TkAgg、Wx or WxAggのいくつかのbackendはGUIグラフィックインタフェースが必要である.
import matplotlib.pyplot as plt
Backend TkAgg is interactive backend. Turning interactive mode on.

plt.get_backend()
Out[3]: u'TkAgg'

解決策:GUI不要のbackend(Agg,Cairo,PS,PDF or SVG)を指定
import matplotlib.pyplot as plt
plt.switch_backend('agg')

 
2、問題:UserWarning:Matplotlib is currently using agg,which is a non-GUI backend,so cannot show the figure
ソリューション:
import matplotlib
matplotlib.use('TkAgg')
 
参照先:
https://www.icode9.com/content-4-32530.html
https://blog.csdn.net/neninee/article/details/87972040#commentsedit