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

Skip to content

Commit b87b138

Browse files
committed
Merge pull request #8506 from Carreau/matplotlib-list
added %matplotlib --list so backends are easily visible (finish #8449)
2 parents b4f9523 + 41b8f2f commit b87b138

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

IPython/core/magics/pylab.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class PylabMagics(Magics):
4242
@skip_doctest
4343
@line_magic
4444
@magic_arguments.magic_arguments()
45+
@magic_arguments.argument('-l', '--list', action='store_true',
46+
help='Show available matplotlib backends')
4547
@magic_gui_arg
4648
def matplotlib(self, line=''):
4749
"""Set up matplotlib to work interactively.
@@ -83,10 +85,20 @@ def matplotlib(self, line=''):
8385
But you can explicitly request a different GUI backend::
8486
8587
In [3]: %matplotlib qt
88+
89+
You can list the available backends using the -l/--list option
90+
91+
In [4]: %matplotlib --list
92+
Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'notebook', 'wx', 'qt', 'nbagg',
93+
'gtk', 'tk', 'inline']
8694
"""
8795
args = magic_arguments.parse_argstring(self.matplotlib, line)
88-
gui, backend = self.shell.enable_matplotlib(args.gui)
89-
self._show_matplotlib_backend(args.gui, backend)
96+
if args.list:
97+
backends_list = list(backends.keys())
98+
print("Available matplotlib backends: %s" % backends_list)
99+
else:
100+
gui, backend = self.shell.enable_matplotlib(args.gui)
101+
self._show_matplotlib_backend(args.gui, backend)
90102

91103
@skip_doctest
92104
@line_magic

0 commit comments

Comments
 (0)