bundles / IPython 9.3.0 / IPython / core / magics / pylab / PylabMagics / matplotlib
function
IPython.core.magics.pylab:PylabMagics.matplotlib
Signature
def matplotlib ( self , line = '' ) Summary
::
Extended Summary
%matplotlib [-l] [gui]
Set up matplotlib to work interactively.
This function lets you activate matplotlib interactive support at any point during an IPython session. It does not import anything into the interactive namespace.
If you are using the inline matplotlib backend in the IPython Notebook you can set which figure formats are enabled using the following
In [1]: from matplotlib_inline.backend_inline import set_matplotlib_formats In [2]: set_matplotlib_formats('pdf', 'svg')
The default for inline figures sets bbox_inches to 'tight'. This can cause discrepancies between the displayed image and the identical image created using savefig. This behavior can be disabled using the %config magic
In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}In addition, see the docstrings of matplotlib_inline.backend_inline.set_matplotlib_formats and matplotlib_inline.backend_inline.set_matplotlib_close for more information on changing additional behaviors of the inline backend.
Examples
To enable the inline backend for usage with the IPython Notebook:: In [1]: %matplotlib inline In this case, where the matplotlib default is TkAgg:: In [2]: %matplotlib Using matplotlib backend: TkAgg But you can explicitly request a different GUI backend:: In [3]: %matplotlib qt You can list the available backends using the -l/--list option:: In [4]: %matplotlib --list Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'gtk4', 'notebook', 'wx', 'qt', 'nbagg', 'gtk', 'tk', 'inline'] positional arguments: gui Name of the matplotlib backend to use such as 'qt' or 'widget'. If given, the corresponding matplotlib backend is used, otherwise it will be matplotlib's default (which you can set in your matplotlib config file). options: -l, --list Show available matplotlib backendsAliases
-
IPython.core.magics.PylabMagics.matplotlib