您如何确定matplotlib使用哪个后端?


97

无论是从Ipython会话内部还是从脚本内部进行交互,您如何确定matplotlib正在使用哪个后端?

Answers:


120

使用该get_backend()函数获取一个字符串,该字符串表示正在使用哪个后端:

>>> import matplotlib
>>> matplotlib.get_backend()
'TkAgg'

8

确定当前后端的另一种方法是读取rcParams字典:

>>> import matplotlib
>>> print (matplotlib.rcParams['backend']) 
MacOSX
>>> matplotlib.use('agg')
>>> print (matplotlib.rcParams['backend']) 
agg
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.