<!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>Introduction — Matplotlib v1.1.1 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.1.1', 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 v1.1.1 documentation" href="../_static/opensearch.xml"/> <link rel="top" title="Matplotlib v1.1.1 documentation" href="../index.html" /> <link rel="up" title="User’s Guide" href="index.html" /> <link rel="next" title="Installing" href="installing.html" /> <link rel="prev" title="User’s Guide" href="index.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="installing.html" title="Installing" accesskey="N">next</a> |</li> <li class="right" > <a href="index.html" title="User’s Guide" 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">User’s Guide</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="index.html" title="previous chapter">User’s Guide</a></p> <h4>Next topic</h4> <p class="topless"><a href="installing.html" title="next chapter">Installing</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/users/intro.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" size="18" /> <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="introduction"> <h1>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h1> <p>matplotlib is a library for making 2D plots of arrays in <a class="reference external" href="http://www.python.org">Python</a>. Although it has its origins in emulating the MATLAB® <a class="footnote-reference" href="#id2" id="id1">[*]</a> graphics commands, it is independent of MATLAB, and can be used in a Pythonic, object oriented way. Although matplotlib is written primarily in pure Python, it makes heavy use of <a class="reference external" href="http://www.numpy.org">NumPy</a> and other extension code to provide good performance even for large arrays.</p> <p>matplotlib is designed with the philosophy that you should be able to create simple plots with just a few commands, or just one! If you want to see a histogram of your data, you shouldn’t need to instantiate objects, call methods, set properties, and so on; it should just work.</p> <p>For years, I used to use MATLAB exclusively for data analysis and visualization. MATLAB excels at making nice looking plots easy. When I began working with EEG data, I found that I needed to write applications to interact with my data, and developed and EEG analysis application in MATLAB. As the application grew in complexity, interacting with databases, http servers, manipulating complex data structures, I began to strain against the limitations of MATLAB as a programming language, and decided to start over in Python. Python more than makes up for all of MATLAB’s deficiencies as a programming language, but I was having difficulty finding a 2D plotting package (for 3D <a class="reference external" href="http://www.vtk.org/">VTK</a> more than exceeds all of my needs).</p> <p>When I went searching for a Python plotting package, I had several requirements:</p> <ul class="simple"> <li>Plots should look great - publication quality. One important requirement for me is that the text looks good (antialiased, etc.)</li> <li>Postscript output for inclusion with TeX documents</li> <li>Embeddable in a graphical user interface for application development</li> <li>Code should be easy enough that I can understand it and extend it</li> <li>Making plots should be easy</li> </ul> <p>Finding no package that suited me just right, I did what any self-respecting Python programmer would do: rolled up my sleeves and dived in. Not having any real experience with computer graphics, I decided to emulate MATLAB’s plotting capabilities because that is something MATLAB does very well. This had the added advantage that many people have a lot of MATLAB experience, and thus they can quickly get up to steam plotting in python. From a developer’s perspective, having a fixed user interface (the pylab interface) has been very useful, because the guts of the code base can be redesigned without affecting user code.</p> <p>The matplotlib code is conceptually divided into three parts: the <em>pylab interface</em> is the set of functions provided by <tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.pylab</span></tt> which allow the user to create plots with code quite similar to MATLAB figure generating code (<a class="reference internal" href="pyplot_tutorial.html#pyplot-tutorial"><em>Pyplot tutorial</em></a>). The <em>matplotlib frontend</em> or <em>matplotlib API</em> is the set of classes that do the heavy lifting, creating and managing figures, text, lines, plots and so on (<a class="reference internal" href="artists.html#artist-tutorial"><em>Artist tutorial</em></a>). This is an abstract interface that knows nothing about output. The <em>backends</em> are device dependent drawing devices, aka renderers, that transform the frontend representation to hardcopy or a display device (<a class="reference internal" href="../faq/usage_faq.html#what-is-a-backend"><em>What is a backend?</em></a>). Example backends: PS creates <a class="reference external" href="http://www.adobe.com/products/postscript/">PostScript®</a> hardcopy, SVG creates <a class="reference external" href="http://www.w3.org/Graphics/SVG/">Scalable Vector Graphics</a> hardcopy, Agg creates PNG output using the high quality <a class="reference external" href="http://www.antigrain.com">Anti-Grain Geometry</a> library that ships with matplotlib, GTK embeds matplotlib in a <a class="reference external" href="http://www.gtk.org/">Gtk+</a> application, GTKAgg uses the Anti-Grain renderer to create a figure and embed it a Gtk+ application, and so on for <a class="reference external" href="http://www.adobe.com/products/acrobat/adobepdf.html">PDF</a>, <a class="reference external" href="http://www.wxpython.org/">WxWidgets</a>, <a class="reference external" href="http://docs.python.org/lib/module-Tkinter.html">Tkinter</a> etc.</p> <p>matplotlib is used by many people in many different contexts. Some people want to automatically generate PostScript files to send to a printer or publishers. Others deploy matplotlib on a web application server to generate PNG output for inclusion in dynamically-generated web pages. Some use matplotlib interactively from the Python shell in Tkinter on Windows™. My primary use is to embed matplotlib in a Gtk+ EEG application that runs on Windows, Linux and Macintosh OS X.</p> <table class="docutils footnote" frame="void" id="id2" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a class="fn-backref" href="#id1">[*]</a></td><td>MATLAB is a registered trademark of The MathWorks, Inc.</td></tr> </tbody> </table> </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="installing.html" title="Installing" >next</a> |</li> <li class="right" > <a href="index.html" title="User’s Guide" >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" >User’s Guide</a> »</li> </ul> </div> <div class="footer"> © Copyright 2008, John Hunter, Darren Dale, Michael Droettboom. Last updated on Oct 04, 2012. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>