You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<divid="unreleased-message"> You are reading an old version of the documentation (v2.1.1). For the latest version see <ahref="https://matplotlib.org/stable/api/pyplot_summary.html">https://matplotlib.org/stable/api/pyplot_summary.html</a></div>
<li><aclass="reference internal" href="#colors-in-matplotlib" id="id13">Colors in Matplotlib</a></li>
</ul>
</div>
<divclass="section" id="the-pyplot-api">
<h1><aclass="toc-backref" href="#id11">The Pyplot API</a><aclass="headerlink" href="#the-pyplot-api" title="Permalink to this headline">¶</a></h1>
<p>The <aclass="reference internal" href="_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-mod docutils literal"><spanclass="pre">matplotlib.pyplot</span></code></a> module contains functions that allow you to generate
many kinds of plots quickly. For examples that showcase the use
of the <aclass="reference internal" href="_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-mod docutils literal"><spanclass="pre">matplotlib.pyplot</span></code></a> module, see the
or the <aclass="reference internal" href="../gallery/index.html#pyplots-examples"><spanclass="std std-ref">Pyplot Examples</span></a>. We also recommend that you look into
the object-oriented approach to plotting, described below.</p>
<dlclass="function">
<dtid="matplotlib.pyplot.plotting">
<codeclass="descclassname">matplotlib.pyplot.</code><codeclass="descname">plotting</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.pyplot.plotting" title="Permalink to this definition">¶</a></dt>
<td>Annotate the point <codeclass="docutils literal"><spanclass="pre">xy</span></code> with text <codeclass="docutils literal"><spanclass="pre">s</span></code>.</td>
<td>Get the current <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">Axes</span></code></a> instance on the current figure matching the given keyword args, or create one.</td>
<td>Create a figure and a set of subplots This utility wrapper makes it convenient to create common layouts of subplots, including the enclosing figure object, in a single call.</td>
<td>Change the <aclass="reference internal" href="ticker_api.html#matplotlib.ticker.ScalarFormatter" title="matplotlib.ticker.ScalarFormatter"><codeclass="xref py py-obj docutils literal"><spanclass="pre">ScalarFormatter</span></code></a> used by default for linear axes.</td>
<td>Get or set the <em>y</em>-limits of the current tick locations and labels.</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<divclass="section" id="the-object-oriented-api">
<h1><aclass="toc-backref" href="#id12">The Object-Oriented API</a><aclass="headerlink" href="#the-object-oriented-api" title="Permalink to this headline">¶</a></h1>
<p>Most of these functions also exist as methods in the
<aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">matplotlib.axes.Axes</span></code></a> class. You can use them with the
“Object Oriented” approach to Matplotlib.</p>
<p>While it is easy to quickly generate plots with the
we recommend using the object-oriented approach for more control
and customization of your plots. See the methods in the
<aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-meth docutils literal"><spanclass="pre">matplotlib.axes.Axes()</span></code></a> class for many of the same plotting functions.
For examples of the OO approach to Matplotlib, see the
<h1><aclass="toc-backref" href="#id13">Colors in Matplotlib</a><aclass="headerlink" href="#colors-in-matplotlib" title="Permalink to this headline">¶</a></h1>
<p>There are many colormaps you can use to map data onto color values.
Below we list several ways in which color can be utilized in Matplotlib.</p>
<p>For a more in-depth look at colormaps, see the
<aclass="reference internal" href="../tutorials/colors/colormaps.html#sphx-glr-tutorials-colors-colormaps-py"><spanclass="std std-ref">Colormaps in Matplotlib</span></a> tutorial.</p>
<dlclass="function">
<dtid="matplotlib.pyplot.colormaps">
<codeclass="descclassname">matplotlib.pyplot.</code><codeclass="descname">colormaps</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.pyplot.colormaps" title="Permalink to this definition">¶</a></dt>
<dd><p>Matplotlib provides a number of colormaps, and others can be added using
<aclass="reference internal" href="cm_api.html#matplotlib.cm.register_cmap" title="matplotlib.cm.register_cmap"><codeclass="xref py py-func docutils literal"><spanclass="pre">register_cmap()</span></code></a>. This function documents the built-in
colormaps, and will also return a list of all registered colormaps if called.</p>
<p>You can set the colormap for an image, pcolor, scatter, etc,
<p>In interactive mode, <aclass="reference internal" href="_as_gen/matplotlib.pyplot.set_cmap.html#matplotlib.pyplot.set_cmap" title="matplotlib.pyplot.set_cmap"><codeclass="xref py py-func docutils literal"><spanclass="pre">set_cmap()</span></code></a> will update the colormap post-hoc,
allowing you to see which one works best for your data.</p>
<p>All built-in colormaps can be reversed by appending <codeclass="docutils literal"><spanclass="pre">_r</span></code>: For instance,
<codeclass="docutils literal"><spanclass="pre">gray_r</span></code> is the reverse of <codeclass="docutils literal"><spanclass="pre">gray</span></code>.</p>
<p>There are several common color schemes used in visualization:</p>
<dlclass="docutils">
<dt>Sequential schemes</dt>
<dd>for unipolar data that progresses from low to high</dd>
<dt>Diverging schemes</dt>
<dd>for bipolar data that emphasizes positive or negative deviations from a
central value</dd>
<dt>Cyclic schemes</dt>
<dd>meant for plotting values that wrap around at the
endpoints, such as phase angle, wind direction, or time of day</dd>
<dt>Qualitative schemes</dt>
<dd>for nominal data that has no inherent ordering, where color is used
only to distinguish categories</dd>
</dl>
<p>Matplotlib ships with 4 perceptually uniform color maps which are
the recommended color maps for sequential data:</p>
<blockquote>
<div><tableborder="1" class="docutils">
<colgroup>
<colwidth="15%" />
<colwidth="85%" />
</colgroup>
<theadvalign="bottom">
<trclass="row-odd"><thclass="head">Colormap</th>
<thclass="head">Description</th>
</tr>
</thead>
<tbodyvalign="top">
<trclass="row-even"><td>inferno</td>
<td>perceptually uniform shades of black-red-yellow</td>
</tr>
<trclass="row-odd"><td>magma</td>
<td>perceptually uniform shades of black-red-white</td>
</tr>
<trclass="row-even"><td>plasma</td>
<td>perceptually uniform shades of blue-red-yellow</td>
</tr>
<trclass="row-odd"><td>viridis</td>
<td>perceptually uniform shades of blue-green-yellow</td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>The following colormaps are based on the <aclass="reference external" href="http://colorbrewer2.org">ColorBrewer</a> color specifications and designs developed by
Cynthia Brewer:</p>
<p>ColorBrewer Diverging (luminance is highest at the midpoint, and
decreases towards differently-colored endpoints):</p>