<!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>configuration — Matplotlib 1.2.0 documentation</title> <link rel="stylesheet" href="../_static/mpl.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.2.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="search" type="application/opensearchdescription+xml" title="Search within Matplotlib 1.2.0 documentation" href="../_static/opensearch.xml"/> <link rel="top" title="Matplotlib 1.2.0 documentation" href="../index.html" /> <link rel="up" title="The Matplotlib API" href="index.html" /> <link rel="next" title="afm (Adobe Font Metrics interface)" href="afm_api.html" /> <link rel="prev" title="API Changes" href="api_changes.html" /> </head> <body> <!-- Piwik --> <script type="text/javascript"> if ("matplotlib.sourceforge.net" == document.location.hostname || "matplotlib.sf.net" == document.location.hostname) { var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); } </script> <script type="text/javascript"> if ("matplotlib.sourceforge.net" == document.location.hostname || "matplotlib.sf.net" == document.location.hostname) { piwik_action_name = ''; piwik_idsite = 1; piwik_url = pkBaseURL + "piwik.php"; piwik_log(piwik_action_name, piwik_idsite, piwik_url); document.write(unescape('%3Cobject%3E%3Cnoscript%3E%3Cp%3E%3Cimg src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/%3E%3C/p%3E%3C/noscript%3E%3C/object%3E')); } </script> <!-- End Piwik Tag --> <link rel="shortcut icon" href="_static/favicon.ico"> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="../index.html"><img src="../_static/logo2.png" border="0" alt="matplotlib"/></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="afm_api.html" title="afm (Adobe Font Metrics interface)" accesskey="N">next</a> |</li> <li class="right" > <a href="api_changes.html" title="API Changes" accesskey="P">previous</a> |</li> <li><a href="../index.html">home</a>| </li> <li><a href="../search.html">search</a>| </li> <li><a href="../examples/index.html">examples</a>| </li> <li><a href="../gallery.html">gallery</a>| </li> <li><a href="../contents.html">docs</a> »</li> <li><a href="index.html" accesskey="U">The Matplotlib API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">configuration</a><ul> <li><a class="reference internal" href="#module-matplotlib"><tt class="docutils literal"><span class="pre">matplotlib</span></tt></a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="api_changes.html" title="previous chapter">API Changes</a></p> <h4>Next topic</h4> <p class="topless"><a href="afm_api.html" title="next chapter">afm (Adobe Font Metrics interface)</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/api/matplotlib_configuration_api.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="configuration"> <h1>configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h1> <div class="section" id="module-matplotlib"> <span id="matplotlib"></span><h2><a class="reference internal" href="#module-matplotlib" title="matplotlib"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib</span></tt></a><a class="headerlink" href="#module-matplotlib" title="Permalink to this headline">¶</a></h2> <p>This is an object-oriented plotting library.</p> <p>A procedural interface is provided by the companion pyplot module, which may be imported directly, e.g:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <p>To include numpy functions too, use:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pylab</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <p>or using ipython:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">ipython</span> <span class="o">-</span><span class="n">pylab</span> </pre></div> </div> <p>For the most part, direct use of the object-oriented library is encouraged when programming; pyplot is primarily for working interactively. The exceptions are the pyplot commands <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.figure" title="matplotlib.pyplot.figure"><tt class="xref py py-func docutils literal"><span class="pre">figure()</span></tt></a>, <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.subplot" title="matplotlib.pyplot.subplot"><tt class="xref py py-func docutils literal"><span class="pre">subplot()</span></tt></a>, <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.subplots" title="matplotlib.pyplot.subplots"><tt class="xref py py-func docutils literal"><span class="pre">subplots()</span></tt></a>, <tt class="xref py py-func docutils literal"><span class="pre">show()</span></tt>, and <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.savefig" title="matplotlib.pyplot.savefig"><tt class="xref py py-func docutils literal"><span class="pre">savefig()</span></tt></a>, which can greatly simplify scripting.</p> <p>Modules include:</p> <blockquote> <div><dl class="docutils"> <dt><a class="reference internal" href="axes_api.html#module-matplotlib.axes" title="matplotlib.axes"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.axes</span></tt></a></dt> <dd>defines the <a class="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><tt class="xref py py-class docutils literal"><span class="pre">Axes</span></tt></a> class. Most pylab commands are wrappers for <a class="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><tt class="xref py py-class docutils literal"><span class="pre">Axes</span></tt></a> methods. The axes module is the highest level of OO access to the library.</dd> <dt><a class="reference internal" href="figure_api.html#module-matplotlib.figure" title="matplotlib.figure"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.figure</span></tt></a></dt> <dd>defines the <a class="reference internal" href="figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><tt class="xref py py-class docutils literal"><span class="pre">Figure</span></tt></a> class.</dd> <dt><a class="reference internal" href="artist_api.html#module-matplotlib.artist" title="matplotlib.artist"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.artist</span></tt></a></dt> <dd>defines the <a class="reference internal" href="artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><tt class="xref py py-class docutils literal"><span class="pre">Artist</span></tt></a> base class for all classes that draw things.</dd> <dt><a class="reference internal" href="artist_api.html#module-matplotlib.lines" title="matplotlib.lines"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.lines</span></tt></a></dt> <dd>defines the <a class="reference internal" href="artist_api.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><tt class="xref py py-class docutils literal"><span class="pre">Line2D</span></tt></a> class for drawing lines and markers</dd> <dt><a class="reference internal" href="artist_api.html#module-matplotlib.patches" title="matplotlib.patches"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.patches</span></tt></a></dt> <dd>defines classes for drawing polygons</dd> <dt><a class="reference internal" href="artist_api.html#module-matplotlib.text" title="matplotlib.text"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.text</span></tt></a></dt> <dd>defines the <a class="reference internal" href="artist_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><tt class="xref py py-class docutils literal"><span class="pre">Text</span></tt></a>, <a class="reference internal" href="artist_api.html#matplotlib.text.TextWithDash" title="matplotlib.text.TextWithDash"><tt class="xref py py-class docutils literal"><span class="pre">TextWithDash</span></tt></a>, and <tt class="xref py py-class docutils literal"><span class="pre">Annotate</span></tt> classes</dd> <dt><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.image</span></tt></dt> <dd>defines the <tt class="xref py py-class docutils literal"><span class="pre">AxesImage</span></tt> and <tt class="xref py py-class docutils literal"><span class="pre">FigureImage</span></tt> classes</dd> <dt><a class="reference internal" href="collections_api.html#module-matplotlib.collections" title="matplotlib.collections"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.collections</span></tt></a></dt> <dd>classes for efficient drawing of groups of lines or polygons</dd> <dt><a class="reference internal" href="colors_api.html#module-matplotlib.colors" title="matplotlib.colors"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.colors</span></tt></a></dt> <dd>classes for interpreting color specifications and for making colormaps</dd> <dt><a class="reference internal" href="cm_api.html#module-matplotlib.cm" title="matplotlib.cm"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.cm</span></tt></a></dt> <dd>colormaps and the <tt class="xref py py-class docutils literal"><span class="pre">ScalarMappable</span></tt> mixin class for providing color mapping functionality to other classes</dd> <dt><a class="reference internal" href="ticker_api.html#module-matplotlib.ticker" title="matplotlib.ticker"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.ticker</span></tt></a></dt> <dd>classes for calculating tick mark locations and for formatting tick labels</dd> <dt><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.backends</span></tt></dt> <dd>a subpackage with modules for various gui libraries and output formats</dd> </dl> </div></blockquote> <p>The base matplotlib namespace includes:</p> <blockquote> <div><dl class="docutils"> <dt><tt class="xref py py-data docutils literal"><span class="pre">rcParams</span></tt></dt> <dd>a global dictionary of default configuration settings. It is initialized by code which may be overridded by a matplotlibrc file.</dd> <dt><a class="reference internal" href="#matplotlib.rc" title="matplotlib.rc"><tt class="xref py py-func docutils literal"><span class="pre">rc()</span></tt></a></dt> <dd>a function for setting groups of rcParams values</dd> <dt><a class="reference internal" href="#matplotlib.use" title="matplotlib.use"><tt class="xref py py-func docutils literal"><span class="pre">use()</span></tt></a></dt> <dd>a function for setting the matplotlib backend. If used, this function must be called immediately after importing matplotlib for the first time. In particular, it must be called <strong>before</strong> importing pylab (if pylab is imported).</dd> </dl> </div></blockquote> <p>matplotlib was initially written by John D. Hunter (1968-2012) and is now developed and maintained by a host of others.</p> <p>Occasionally the internal documentation (python docstrings) will refer to MATLAB&reg;, a registered trademark of The MathWorks, Inc.</p> <dl class="function"> <dt id="matplotlib.rc"> <tt class="descclassname">matplotlib.</tt><tt class="descname">rc</tt><big>(</big><em>group</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#matplotlib.rc" title="Permalink to this definition">¶</a></dt> <dd><p>Set the current rc params. Group is the grouping for the rc, eg. for <tt class="docutils literal"><span class="pre">lines.linewidth</span></tt> the group is <tt class="docutils literal"><span class="pre">lines</span></tt>, for <tt class="docutils literal"><span class="pre">axes.facecolor</span></tt>, the group is <tt class="docutils literal"><span class="pre">axes</span></tt>, and so on. Group may also be a list or tuple of group names, eg. (<em>xtick</em>, <em>ytick</em>). <em>kwargs</em> is a dictionary attribute name/value pairs, eg:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">rc</span><span class="p">(</span><span class="s">'lines'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">'r'</span><span class="p">)</span> </pre></div> </div> <p>sets the current rc params and is equivalent to:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">rcParams</span><span class="p">[</span><span class="s">'lines.linewidth'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">2</span> <span class="n">rcParams</span><span class="p">[</span><span class="s">'lines.color'</span><span class="p">]</span> <span class="o">=</span> <span class="s">'r'</span> </pre></div> </div> <p>The following aliases are available to save typing for interactive users:</p> <table border="1" class="docutils"> <colgroup> <col width="23%" /> <col width="77%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Alias</th> <th class="head">Property</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>‘lw’</td> <td>‘linewidth’</td> </tr> <tr class="row-odd"><td>‘ls’</td> <td>‘linestyle’</td> </tr> <tr class="row-even"><td>‘c’</td> <td>‘color’</td> </tr> <tr class="row-odd"><td>‘fc’</td> <td>‘facecolor’</td> </tr> <tr class="row-even"><td>‘ec’</td> <td>‘edgecolor’</td> </tr> <tr class="row-odd"><td>‘mew’</td> <td>‘markeredgewidth’</td> </tr> <tr class="row-even"><td>‘aa’</td> <td>‘antialiased’</td> </tr> </tbody> </table> <p>Thus you could abbreviate the above rc command as:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">rc</span><span class="p">(</span><span class="s">'lines'</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="s">'r'</span><span class="p">)</span> </pre></div> </div> <p>Note you can use python’s kwargs dictionary facility to store dictionaries of default parameters. Eg, you can customize the font rc as follows:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">font</span> <span class="o">=</span> <span class="p">{</span><span class="s">'family'</span> <span class="p">:</span> <span class="s">'monospace'</span><span class="p">,</span> <span class="s">'weight'</span> <span class="p">:</span> <span class="s">'bold'</span><span class="p">,</span> <span class="s">'size'</span> <span class="p">:</span> <span class="s">'larger'</span><span class="p">}</span> <span class="n">rc</span><span class="p">(</span><span class="s">'font'</span><span class="p">,</span> <span class="o">**</span><span class="n">font</span><span class="p">)</span> <span class="c"># pass in the font dict as kwargs</span> </pre></div> </div> <p>This enables you to easily switch between several configurations. Use <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.rcdefaults" title="matplotlib.pyplot.rcdefaults"><tt class="xref py py-func docutils literal"><span class="pre">rcdefaults()</span></tt></a> to restore the default rc params after changes.</p> </dd></dl> <dl class="function"> <dt id="matplotlib.rcdefaults"> <tt class="descclassname">matplotlib.</tt><tt class="descname">rcdefaults</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.rcdefaults" title="Permalink to this definition">¶</a></dt> <dd><p>Restore the default rc params. These are not the params loaded by the rc file, but mpl’s internal params. See rc_file_defaults for reloading the default params from the rc file</p> </dd></dl> <dl class="function"> <dt id="matplotlib.use"> <tt class="descclassname">matplotlib.</tt><tt class="descname">use</tt><big>(</big><em>arg</em>, <em>warn=True</em>, <em>force=False</em><big>)</big><a class="headerlink" href="#matplotlib.use" title="Permalink to this definition">¶</a></dt> <dd><p>Set the matplotlib backend to one of the known backends.</p> <p>The argument is case-insensitive. <em>warn</em> specifies whether a warning should be issued if a backend has already been set up. <em>force</em> is an <strong>experimental</strong> flag that tells matplotlib to attempt to initialize a new backend by reloading the backend module.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This function must be called <em>before</em> importing pyplot for the first time; or, if you are not using pyplot, it must be called before importing matplotlib.backends. If warn is True, a warning is issued if you try and call this after pylab or pyplot have been loaded. In certain black magic use cases, e.g. <a class="reference internal" href="pyplot_api.html#matplotlib.pyplot.switch_backend" title="matplotlib.pyplot.switch_backend"><tt class="xref py py-func docutils literal"><span class="pre">pyplot.switch_backend()</span></tt></a>, we are doing the reloading necessary to make the backend switch work (in some cases, e.g. pure image backends) so one can set warn=False to suppress the warnings.</p> </div> <p>To find out which backend is currently set, see <tt class="xref py py-func docutils literal"><span class="pre">matplotlib.get_backend()</span></tt>.</p> </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="afm_api.html" title="afm (Adobe Font Metrics interface)" >next</a> |</li> <li class="right" > <a href="api_changes.html" title="API Changes" >previous</a> |</li> <li><a href="../index.html">home</a>| </li> <li><a href="../search.html">search</a>| </li> <li><a href="../examples/index.html">examples</a>| </li> <li><a href="../gallery.html">gallery</a>| </li> <li><a href="../contents.html">docs</a> »</li> <li><a href="index.html" >The Matplotlib API</a> »</li> </ul> </div> <div class="footer"> © Copyright 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the matplotlib development team. Last updated on Jul 23, 2013. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>