matplotlib.backends.registry#
- classmatplotlib.backends.registry.BackendFilter(*values)[source]#
Bases:
EnumFilter used with
list_builtin()Added in version 3.9.
- classmatplotlib.backends.registry.BackendRegistry[source]#
Bases:
objectRegistry of backends available within Matplotlib.
This is the single source of truth for available backends.
All use of
BackendRegistryshould be via the singleton instancebackend_registrywhich can be imported frommatplotlib.backends.Each backend has a name, a module name containing the backend code, and anoptional GUI framework that must be running if the backend is interactive.There are three sources of backends: built-in (source code is within theMatplotlib repository), explicit
module://some.backendsyntax (backend isobtained by loading the module), or via an entry point (self-registeringbackend in an external package).Added in version 3.9.
- backend_for_gui_framework(framework)[source]#
Return the name of the backend corresponding to the specified GUI framework.
- Parameters:
- frameworkstr
GUI framework such as "qt".
- Returns:
- str or None
Backend name or None if GUI framework not recognised.
- is_valid_backend(backend)[source]#
Return True if the backend name is valid, False otherwise.
A backend name is valid if it is one of the built-in backends or has beendynamically added via an entry point. Those beginning with
module://arealways considered valid and are added to the current list of all backendswithin this function.Even if a name is valid, it may not be importable or usable. This can only bedetermined by loading and using the backend module.
- Parameters:
- backendstr
Name of backend.
- Returns:
- bool
True if backend is valid, False otherwise.
- list_all()[source]#
Return list of all known backends.
These include built-in backends and those obtained at runtime either from entrypoints or explicit
module://some.backendsyntax.Entry points will be loaded if they haven't been already.
- Returns:
- list of str
Backend names.
- list_builtin(filter_=None)[source]#
Return list of backends that are built into Matplotlib.
- Parameters:
- filter_
BackendFilter, optional Filter to apply to returned backends. For example, to return onlynon-interactive backends use
BackendFilter.NON_INTERACTIVE.
- filter_
- Returns:
- list of str
Backend names.
- list_gui_frameworks()[source]#
Return list of GUI frameworks used by Matplotlib backends.
- Returns:
- list of str
GUI framework names.
- load_backend_module(backend)[source]#
Load and return the module containing the specified backend.
- Parameters:
- backendstr
Name of backend to load.
- Returns:
- Module
Module containing backend.
- resolve_backend(backend)[source]#
Return the backend and GUI framework for the specified backend name.
If the GUI framework is not yet known then it will be determined by loading thebackend module and checking the
FigureCanvas.required_interactive_frameworkattribute.This function only loads entry points if they have not already been loaded andthe backend is not built-in and not of
module://some.backendformat.- Parameters:
- backendstr or None
Name of backend, or None to use the default backend.
- Returns:
- backendstr
The backend name.
- frameworkstr or None
The GUI framework, which will be None for a backend that is non-interactive.
- resolve_gui_or_backend(gui_or_backend)[source]#
Return the backend and GUI framework for the specified string that may beeither a GUI framework or a backend name, tested in that order.
This is for use with the IPython %matplotlib magic command which may be a GUIframework such as
%matplotlibqtor a backend name such as%matplotlibqtagg.This function only loads entry points if they have not already been loaded andthe backend is not built-in and not of
module://some.backendformat.- Parameters:
- gui_or_backendstr or None
Name of GUI framework or backend, or None to use the default backend.
- Returns:
- backendstr
The backend name.
- frameworkstr or None
The GUI framework, which will be None for a backend that is non-interactive.