Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: get_backend return None if no backend set #12592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,14 +1361,29 @@ def use(arg, warn=True, force=False):
rcParams['backend'] = os.environ.get('MPLBACKEND')


def get_backend():
def get_backend(fallback=False):
"""
Return the name of the current backend.

Parameters
----------
fallback : bool
Search and set a valid backend before returning the backend's name.
Default is False.

Returns
-------
backend : str
Return the backend's name. The string "None" means the backend has
not been set yet.

See Also
--------
matplotlib.use
"""
val = dict.__getitem__(rcParams, 'backend')
if val is rcsetup._auto_backend_sentinel:
return "None"
return rcParams['backend']


Expand Down