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

Skip to content
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3523,6 +3523,9 @@ class Show(ShowBase):
def mainloop(self):
return cls.mainloop()

if not hasattr(sys.modules[cls.__module__], "Backend"):
setattr(sys.modules[cls.__module__], "Backend", cls)

setattr(sys.modules[cls.__module__], "Show", Show)
return cls

Expand Down
12 changes: 10 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,16 @@ def switch_backend(newbackend):

backend_name = cbook._backend_module_name(newbackend)

class backend_mod(matplotlib.backend_bases._Backend):
locals().update(vars(importlib.import_module(backend_name)))
backend_mod = importlib.import_module(backend_name)
if hasattr(backend_mod, "Backend"):
backend_mod = backend_mod.Backend
else:
class backend_mod(matplotlib.backend_bases._Backend):
locals().update(vars(backend_mod))

@classmethod
def mainloop(cls):
return backend_mod.Show().mainloop()

required_framework = _get_required_interactive_framework(backend_mod)
if required_framework is not None:
Expand Down