无论是交互式的,例如从 Ipython 会话内部,还是从脚本内部,您如何确定 matplotlib 正在使用哪个后端?
Use the get_backend() function to obtain a string denoting which backend is in use:
get_backend()
>>> import matplotlib >>> matplotlib.get_backend() 'TkAgg'
确定当前后端的另一种方法是阅读 rcParams字典:
rcParams
>>> import matplotlib >>> print (matplotlib.rcParams['backend']) MacOSX >>> matplotlib.use('agg') >>> print (matplotlib.rcParams['backend']) agg