<divid="unreleased-message"> You are reading an old version of the documentation (v3.0.2). For the latest version see <ahref="/stable/">https://matplotlib.org/stable/</a></div>
<li><aclass="reference internal" href="#the-pylab-api-disapproved" id="id4">The pylab API (disapproved)</a></li>
</ul>
</li>
</ul>
</div>
<divclass="section" id="the-pyplot-api">
<h2><aclass="toc-backref" href="#id2">The pyplot API</a><aclass="headerlink" href="#the-pyplot-api" title="Permalink to this headline">¶</a></h2>
<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
<h2><aclass="toc-backref" href="#id3">The object-oriented API</a><aclass="headerlink" href="#the-object-oriented-api" title="Permalink to this headline">¶</a></h2>
<p>At its core, Matbplotlib 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>
<li>The list of <aclass="reference internal" href="index.html"><spanclass="doc">matplotlib modules</span></a>.</li>
<h2><aclass="toc-backref" href="#id4">The pylab API (disapproved)</a><aclass="headerlink" href="#the-pylab-api-disapproved" title="Permalink to this headline">¶</a></h2>
<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>
instead.</p>
</div>
<p><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.pylab</span></code> is a module that includes <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>, <aclass="reference external" href="https://docs.scipy.org/doc/numpy/reference/index.html#module-numpy" title="(in NumPy v1.15)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">numpy</span></code></a>
and some additional functions within a single namespace. It's original puropse
was to mimic a MATLAB-like way of working by importing all functions into the
global namespace. This is considered bad style nowadays.</p>