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

PythonMatplotlib

Python Problem Overview


Either interactively, such as from within an Ipython session, or from within a script, how can you determine which backend is being used by matplotlib?

Python Solutions


Solution 1 - Python

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

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

Solution 2 - Python

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatthew RankinView Question on Stackoverflow
Solution 1 - PythonAndrewView Answer on Stackoverflow
Solution 2 - PythonSerenityView Answer on Stackoverflow