Matthew Rankin
Matthew Rankin

Reputation: 461197

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

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?

Upvotes: 120

Views: 41797

Answers (2)

Andrew
Andrew

Reputation: 13191

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

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

Upvotes: 161

Serenity
Serenity

Reputation: 36695

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

Upvotes: 10

Related Questions