How do you determine which backend is being used by matplotlib?

Solution 1:

Use the get_backend() function to obtain a string denoting which backend is in use:

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

Solution 2:

Another way to determine the current backend is to read rcParams dictionary:

>>> import matplotlib
>>> print (matplotlib.rcParams['backend']) 
MacOSX
>>> matplotlib.use('agg')
>>> print (matplotlib.rcParams['backend']) 
agg