115

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?

Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163

2 Answers2

152

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

>>> import matplotlib
>>> matplotlib.get_backend()
'TkAgg'
Niko Föhr
  • 28,336
  • 10
  • 93
  • 96
Andrew
  • 12,821
  • 2
  • 26
  • 18
10

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
Serenity
  • 35,289
  • 20
  • 120
  • 115