<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Module: core.magics.pylab — IPython 2.3.0 documentation</title> <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '2.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="top" title="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: core.magics.script" href="IPython.core.magics.script.html" /> <link rel="prev" title="Module: core.magics.osm" href="IPython.core.magics.osm.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.magics.script.html" title="Module: core.magics.script" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.core.magics.osm.html" title="Module: core.magics.osm" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">core.magics.pylab</span></tt></a><ul> <li><a class="reference internal" href="#class">1 Class</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.core.magics.osm.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.osm</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.core.magics.script.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.script</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.core.magics.pylab.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.core.magics.pylab"> <span id="module-core-magics-pylab"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.magics.pylab</span></tt><a class="headerlink" href="#module-IPython.core.magics.pylab" title="Permalink to this headline">¶</a></h1> <p>Implementation of magic functions for matplotlib/pylab support.</p> <div class="section" id="class"> <h2>1 Class<a class="headerlink" href="#class" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.core.magics.pylab.PylabMagics"> <em class="property">class </em><tt class="descclassname">IPython.core.magics.pylab.</tt><tt class="descname">PylabMagics</tt><big>(</big><em>shell=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#IPython.core.magics.pylab.PylabMagics" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="IPython.core.magic.html#IPython.core.magic.Magics" title="IPython.core.magic.Magics"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.magic.Magics</span></tt></a></p> <p>Magics related to matplotlib’s pylab support</p> <dl class="method"> <dt id="IPython.core.magics.pylab.PylabMagics.matplotlib"> <tt class="descname">matplotlib</tt><big>(</big><em>line=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.pylab.PylabMagics.matplotlib" title="Permalink to this definition">¶</a></dt> <dd><div class="highlight-python"><div class="highlight"><pre>%matplotlib [gui] </pre></div> </div> <p>Set up matplotlib to work interactively.</p> <p>This function lets you activate matplotlib interactive support at any point during an IPython session. It does not import anything into the interactive namespace.</p> <p>If you are using the inline matplotlib backend in the IPython Notebook you can set which figure formats are enabled using the following:</p> <div class="highlight-python"><div class="highlight"><pre>In [1]: from IPython.display import set_matplotlib_formats In [2]: set_matplotlib_formats('pdf', 'svg') </pre></div> </div> <p>See the docstring of <cite>IPython.display.set_matplotlib_formats</cite> and <cite>IPython.display.set_matplotlib_close</cite> for more information on changing the behavior of the inline backend.</p> <p class="rubric">Examples</p> <p>To enable the inline backend for usage with the IPython Notebook:</p> <div class="highlight-python"><div class="highlight"><pre>In [1]: %matplotlib inline </pre></div> </div> <p>In this case, where the matplotlib default is TkAgg:</p> <div class="highlight-python"><div class="highlight"><pre>In [2]: %matplotlib Using matplotlib backend: TkAgg </pre></div> </div> <p>But you can explicitly request a different GUI backend:</p> <div class="highlight-python"><div class="highlight"><pre>In [3]: %matplotlib qt </pre></div> </div> <dl class="docutils"> <dt>positional arguments:</dt> <dd><dl class="first last docutils"> <dt>gui Name of the matplotlib backend to use (‘gtk’, ‘gtk3’, ‘inline’,</dt> <dd>‘nbagg’, ‘osx’, ‘qt’, ‘qt4’, ‘qt5’, ‘tk’, ‘wx’). If given, the corresponding matplotlib backend is used, otherwise it will be matplotlib’s default (which you can set in your matplotlib config file).</dd> </dl> </dd> </dl> </dd></dl> <dl class="method"> <dt id="IPython.core.magics.pylab.PylabMagics.pylab"> <tt class="descname">pylab</tt><big>(</big><em>line=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.pylab.PylabMagics.pylab" title="Permalink to this definition">¶</a></dt> <dd><div class="highlight-python"><div class="highlight"><pre>%pylab [--no-import-all] [gui] </pre></div> </div> <p>Load numpy and matplotlib to work interactively.</p> <p>This function lets you activate pylab (matplotlib, numpy and interactive support) at any point during an IPython session.</p> <p>%pylab makes the following imports:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="kn">from</span> <span class="nn">matplotlib</span> <span class="kn">import</span> <span class="n">pylab</span><span class="p">,</span> <span class="n">mlab</span><span class="p">,</span> <span class="n">pyplot</span> <span class="n">np</span> <span class="o">=</span> <span class="n">numpy</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">pyplot</span> <span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">display</span> <span class="kn">from</span> <span class="nn">IPython.core.pylabtools</span> <span class="kn">import</span> <span class="n">figsize</span><span class="p">,</span> <span class="n">getfigs</span> <span class="kn">from</span> <span class="nn">pylab</span> <span class="kn">import</span> <span class="o">*</span> <span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <p>If you pass <cite>–no-import-all</cite>, the last two <cite>*</cite> imports will be excluded.</p> <p>See the %matplotlib magic for more details about activating matplotlib without affecting the interactive namespace.</p> <dl class="docutils"> <dt>positional arguments:</dt> <dd><dl class="first last docutils"> <dt>gui Name of the matplotlib backend to use (‘gtk’, ‘gtk3’,</dt> <dd>‘inline’, ‘nbagg’, ‘osx’, ‘qt’, ‘qt4’, ‘qt5’, ‘tk’, ‘wx’). If given, the corresponding matplotlib backend is used, otherwise it will be matplotlib’s default (which you can set in your matplotlib config file).</dd> </dl> </dd> <dt>optional arguments:</dt> <dd><table class="first last docutils option-list" frame="void" rules="none"> <col class="option" /> <col class="description" /> <tbody valign="top"> <tr><td class="option-group" colspan="2"> <kbd><span class="option">--no-import-all</span></kbd></td> </tr> <tr><td> </td><td>Prevent IPython from performing <tt class="docutils literal"><span class="pre">import</span> <span class="pre">*</span></tt> into the interactive namespace. You can govern the default behavior of this flag with the InteractiveShellApp.pylab_import_all configurable.</td></tr> </tbody> </table> </dd> </dl> </dd></dl> </dd></dl> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.magics.script.html" title="Module: core.magics.script" >next</a> |</li> <li class="right" > <a href="IPython.core.magics.osm.html" title="Module: core.magics.osm" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Sep 02, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>