<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.2). For the latest version see <ahref="https://matplotlib.org/stable/api/index.html">https://matplotlib.org/stable/api/index.html</a></div>
<p>See also the <aclass="reference internal" href="api_changes.html"><spanclass="doc">API Changes</span></a>.</p>
<divclass="section" id="usage-patterns">
<h2><aclass="toc-backref" href="#id1">Usage patterns</a><aclass="headerlink" href="#usage-patterns" title="Permalink to this headline">¶</a></h2>
<p>Below we describe several common approaches to plotting with Matplotlib.</p>
<divclass="section" id="the-pyplot-api">
<h3><aclass="toc-backref" href="#id2">The pyplot API</a><aclass="headerlink" href="#the-pyplot-api" title="Permalink to this headline">¶</a></h3>
<p><aclass="reference internal" href="_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.pyplot</span></code></a> is a collection of command style functions that make
Matplotlib work like MATLAB. Each pyplot function makes some change to a
figure: e.g., creates a figure, creates a plotting area in a figure, plots
some lines in a plotting area, decorates the plot with labels, etc.</p>
<p><aclass="reference internal" href="_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">pyplot</span></code></a> is mainly intended for interactive plots and simple cases of
<spanid="api-index"></span><h3><aclass="toc-backref" href="#id3">The object-oriented API</a><aclass="headerlink" href="#the-object-oriented-api" title="Permalink to this headline">¶</a></h3>
<p>At its core, Matplotlib is object-oriented. We recommend directly working
with the objects, if you need more control and customization of your plots.</p>
<p>In many cases you will create a <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure</span></code></a> and one or more
<aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> using <aclass="reference internal" href="_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots" title="matplotlib.pyplot.subplots"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">pyplot.subplots</span></code></a> and from then on only work
on these objects. However, it's also possible to create <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure</span></code></a>s
explicitly (e.g. when including them in GUI applications).</p>
<p>Further reading:</p>
<ulclass="simple">
<li><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.axes.Axes</span></code></a> and <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.figure.Figure</span></code></a> for an overview of
plotting functions.</li>
<li>Most of the <aclass="reference internal" href="../gallery/index.html#examples-index"><spanclass="std std-ref">examples</span></a> use the object-oriented approach
(except for the pyplot section)</li>
</ul>
</div>
<divclass="section" id="module-pylab">
<spanid="the-pylab-api-disapproved"></span><h3><aclass="toc-backref" href="#id4">The pylab API (disapproved)</a><aclass="headerlink" href="#module-pylab" title="Permalink to this headline">¶</a></h3>
<divclass="admonition warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">Since heavily importing into the global namespace may result in unexpected
behavior, the use of pylab is strongly discouraged. Use <aclass="reference internal" href="_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.pyplot</span></code></a>
<h2><aclass="toc-backref" href="#id6">Toolkits</a><aclass="headerlink" href="#toolkits" title="Permalink to this headline">¶</a></h2>
<p><aclass="reference internal" href="toolkits/index.html#toolkits-index"><spanclass="std std-ref">Toolkits</span></a> are collections of application-specific functions that extend
Matplotlib. The following toolkits are included:</p>