##// END OF EJS Templates
Fix %matplotlib...
Oriol (Prodesk) -
Show More
@@ -37,7 +37,7 b' magic_gui_arg = magic_arguments.argument('
37 37 @magics_class
38 38 class PylabMagics(Magics):
39 39 """Magics related to matplotlib's pylab support"""
40
40
41 41 @skip_doctest
42 42 @line_magic
43 43 @magic_arguments.magic_arguments()
@@ -46,23 +46,23 b' class PylabMagics(Magics):'
46 46 @magic_gui_arg
47 47 def matplotlib(self, line=''):
48 48 """Set up matplotlib to work interactively.
49
49
50 50 This function lets you activate matplotlib interactive support
51 51 at any point during an IPython session. It does not import anything
52 52 into the interactive namespace.
53
53
54 54 If you are using the inline matplotlib backend in the IPython Notebook
55 55 you can set which figure formats are enabled using the following::
56
56
57 57 In [1]: from IPython.display import set_matplotlib_formats
58
58
59 59 In [2]: set_matplotlib_formats('pdf', 'svg')
60 60
61 61 The default for inline figures sets `bbox_inches` to 'tight'. This can
62 62 cause discrepancies between the displayed image and the identical
63 63 image created using `savefig`. This behavior can be disabled using the
64 64 `%config` magic::
65
65
66 66 In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}
67 67
68 68 In addition, see the docstring of
@@ -73,7 +73,7 b' class PylabMagics(Magics):'
73 73 Examples
74 74 --------
75 75 To enable the inline backend for usage with the IPython Notebook::
76
76
77 77 In [1]: %matplotlib inline
78 78
79 79 In this case, where the matplotlib default is TkAgg::
@@ -96,7 +96,7 b' class PylabMagics(Magics):'
96 96 backends_list = list(backends.keys())
97 97 print("Available matplotlib backends: %s" % backends_list)
98 98 else:
99 gui, backend = self.shell.enable_matplotlib(args.gui.lower())
99 gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
100 100 self._show_matplotlib_backend(args.gui, backend)
101 101
102 102 @skip_doctest
@@ -105,7 +105,7 b' class PylabMagics(Magics):'
105 105 @magic_arguments.argument(
106 106 '--no-import-all', action='store_true', default=None,
107 107 help="""Prevent IPython from performing ``import *`` into the interactive namespace.
108
108
109 109 You can govern the default behavior of this flag with the
110 110 InteractiveShellApp.pylab_import_all configurable.
111 111 """
@@ -116,23 +116,23 b' class PylabMagics(Magics):'
116 116
117 117 This function lets you activate pylab (matplotlib, numpy and
118 118 interactive support) at any point during an IPython session.
119
119
120 120 %pylab makes the following imports::
121
121
122 122 import numpy
123 123 import matplotlib
124 124 from matplotlib import pylab, mlab, pyplot
125 125 np = numpy
126 126 plt = pyplot
127
127
128 128 from IPython.display import display
129 129 from IPython.core.pylabtools import figsize, getfigs
130
130
131 131 from pylab import *
132 132 from numpy import *
133 133
134 134 If you pass `--no-import-all`, the last two `*` imports will be excluded.
135
135
136 136 See the %matplotlib magic for more details about activating matplotlib
137 137 without affecting the interactive namespace.
138 138 """
@@ -159,7 +159,7 b' class PylabMagics(Magics):'
159 159 warn("pylab import has clobbered these variables: %s" % clobbered +
160 160 "\n`%matplotlib` prevents importing * from pylab and numpy"
161 161 )
162
162
163 163 def _show_matplotlib_backend(self, gui, backend):
164 164 """show matplotlib message backend message"""
165 165 if not gui or gui == 'auto':
General Comments 0
You need to be logged in to leave comments. Login now