<divid="unreleased-message"> You are reading an old version of the documentation (v1.3.1). For the latest version see <ahref="https://matplotlib.org/stable/api/colors_api.html">https://matplotlib.org/stable/api/colors_api.html</a></div>
<spanid="matplotlib-colors"></span><h2><aclass="reference internal" href="#module-matplotlib.colors" title="matplotlib.colors"><ttclass="xref py py-mod docutils literal"><spanclass="pre">matplotlib.colors</span></tt></a><aclass="headerlink" href="#module-matplotlib.colors" title="Permalink to this headline">¶</a></h2>
<p>A module for converting numbers or color arguments to <em>RGB</em> or <em>RGBA</em></p>
<p><em>RGB</em> and <em>RGBA</em> are sequences of, respectively, 3 or 4 floats in the
range 0-1.</p>
<p>This module includes functions and classes for color specification
conversions, and for mapping numbers to colors in a 1-D array of colors called
a colormap. Colormapping typically involves two steps: a data array is first
mapped onto the range 0-1 using an instance of <aclass="reference internal" href="#matplotlib.colors.Normalize" title="matplotlib.colors.Normalize"><ttclass="xref py py-class docutils literal"><spanclass="pre">Normalize</span></tt></a> or of a
subclass; then this number in the 0-1 range is mapped to a color using an
instance of a subclass of <aclass="reference internal" href="#matplotlib.colors.Colormap" title="matplotlib.colors.Colormap"><ttclass="xref py py-class docutils literal"><spanclass="pre">Colormap</span></tt></a>. Two are provided here:
<aclass="reference internal" href="#matplotlib.colors.LinearSegmentedColormap" title="matplotlib.colors.LinearSegmentedColormap"><ttclass="xref py py-class docutils literal"><spanclass="pre">LinearSegmentedColormap</span></tt></a>, which is used to generate all the built-in
colormap instances, but is also useful for making custom colormaps, and
<aclass="reference internal" href="#matplotlib.colors.ListedColormap" title="matplotlib.colors.ListedColormap"><ttclass="xref py py-class docutils literal"><spanclass="pre">ListedColormap</span></tt></a>, which is used for generating a custom colormap from a
list of color specifications.</p>
<p>The module also provides a single instance, <em>colorConverter</em>, of the
<aclass="reference internal" href="#matplotlib.colors.ColorConverter" title="matplotlib.colors.ColorConverter"><ttclass="xref py py-class docutils literal"><spanclass="pre">ColorConverter</span></tt></a> class providing methods for converting single color
specifications or sequences of them to <em>RGB</em> or <em>RGBA</em>.</p>
<p>Commands which take color arguments can use several formats to specify
the colors. For the basic built-in colors, you can use a single letter</p>
<blockquote>
<div><ulclass="simple">
<li>b: blue</li>
<li>g: green</li>
<li>r: red</li>
<li>c: cyan</li>
<li>m: magenta</li>
<li>y: yellow</li>
<li>k: black</li>
<li>w: white</li>
</ul>
</div></blockquote>
<p>Gray shades can be given as a string encoding a float in the 0-1 range, e.g.:</p>
<p>or you can pass an <em>R</em> , <em>G</em> , <em>B</em> tuple, where each of <em>R</em> , <em>G</em> , <em>B</em> are in
the range [0,1].</p>
<p>Finally, legal html names for colors, like ‘red’, ‘burlywood’ and ‘chartreuse’
are supported.</p>
<dlclass="class">
<dtid="matplotlib.colors.BoundaryNorm">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">BoundaryNorm</tt><big>(</big><em>boundaries</em>, <em>ncolors</em>, <em>clip=False</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.BoundaryNorm" title="Permalink to this definition">¶</a></dt>
<aclass="reference internal" href="#matplotlib.colors.BoundaryNorm" title="matplotlib.colors.BoundaryNorm"><ttclass="xref py py-class docutils literal"><spanclass="pre">BoundaryNorm</span></tt></a> maps values to integers instead of to the
interval 0-1.</p>
<p>Mapping to the 0-1 interval could have been done via
piece-wise linear interpolation, but using integers seems
simpler, and reduces the number of conversions back and forth
between integer and floating point.</p>
<dlclass="docutils">
<dt><em>boundaries</em></dt>
<dd>a monotonically increasing sequence</dd>
<dt><em>ncolors</em></dt>
<dd>number of colors in the colormap to be used</dd>
<ttclass="descname">inverse</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.BoundaryNorm.inverse" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.ColorConverter">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">ColorConverter</tt><aclass="headerlink" href="#matplotlib.colors.ColorConverter" title="Permalink to this definition">¶</a></dt>
<p>Provides methods for converting color specifications to <em>RGB</em> or <em>RGBA</em></p>
<p>Caching is used for more efficient conversion upon repeated calls
with the same argument.</p>
<p>Ordinarily only the single instance instantiated in this module,
<em>colorConverter</em>, is needed.</p>
<dlclass="attribute">
<dtid="matplotlib.colors.ColorConverter.cache">
<ttclass="descname">cache</tt><emclass="property"> = {}</em><aclass="headerlink" href="#matplotlib.colors.ColorConverter.cache" title="Permalink to this definition">¶</a></dt>
<ttclass="descname">to_rgb</tt><big>(</big><em>arg</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.ColorConverter.to_rgb" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an <em>RGB</em> tuple of three floats from 0-1.</p>
<p><em>arg</em> can be an <em>RGB</em> or <em>RGBA</em> sequence or a string in any of
several forms:</p>
<blockquote>
<div><olclass="arabic simple">
<li>a letter from the set ‘rgbcmykw’</li>
<li>a hex color string, like ‘#00FFFF’</li>
<li>a standard name, like ‘aqua’</li>
<li>a float, like ‘0.4’, indicating gray on a 0-1 scale</li>
</ol>
</div></blockquote>
<p>if <em>arg</em> is <em>RGBA</em>, the <em>A</em> will simply be discarded.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.ColorConverter.to_rgba">
<ttclass="descname">to_rgba</tt><big>(</big><em>arg</em>, <em>alpha=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.ColorConverter.to_rgba" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an <em>RGBA</em> tuple of four floats from 0-1.</p>
<p>For acceptable values of <em>arg</em>, see <aclass="reference internal" href="#matplotlib.colors.ColorConverter.to_rgb" title="matplotlib.colors.ColorConverter.to_rgb"><ttclass="xref py py-meth docutils literal"><spanclass="pre">to_rgb()</span></tt></a>.
In addition, if <em>arg</em> is “none” (case-insensitive),
then (0,0,0,0) will be returned.
If <em>arg</em> is an <em>RGBA</em> sequence and <em>alpha</em> is not <em>None</em>,
<em>alpha</em> will replace the original <em>A</em>.</p>
<ttclass="descname">to_rgba_array</tt><big>(</big><em>c</em>, <em>alpha=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.ColorConverter.to_rgba_array" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a numpy array of <em>RGBA</em> tuples.</p>
<p>Accepts a single mpl color spec or a sequence of specs.</p>
<p>Special case to handle “no color”: if <em>c</em> is “none” (case-insensitive),
then an empty array will be returned. Same for an empty list.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.Colormap">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">Colormap</tt><big>(</big><em>name</em>, <em>N=256</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Colormap" title="Permalink to this definition">¶</a></dt>
<p>Typically Colormap instances are used to convert data values (floats) from
the interval <ttclass="docutils literal"><spanclass="pre">[0,</span><spanclass="pre">1]</span></tt> to the RGBA color that the respective Colormap
represents. For scaling of data into the <ttclass="docutils literal"><spanclass="pre">[0,</span><spanclass="pre">1]</span></tt> interval see
<aclass="reference internal" href="#matplotlib.colors.Normalize" title="matplotlib.colors.Normalize"><ttclass="xref py py-class docutils literal"><spanclass="pre">matplotlib.colors.Normalize</span></tt></a>. It is worth noting that
<aclass="reference internal" href="cm_api.html#matplotlib.cm.ScalarMappable" title="matplotlib.cm.ScalarMappable"><ttclass="xref py py-class docutils literal"><spanclass="pre">matplotlib.cm.ScalarMappable</span></tt></a> subclasses make heavy use of this
<ttclass="descname">colorbar_extend</tt><emclass="property"> = None</em><aclass="headerlink" href="#matplotlib.colors.Colormap.colorbar_extend" title="Permalink to this definition">¶</a></dt>
<dd><p>When this colormap exists on a scalar mappable and colorbar_extend
is not False, colorbar creation will pick up <ttclass="docutils literal"><spanclass="pre">colorbar_extend</span></tt> as
the default value for the <ttclass="docutils literal"><spanclass="pre">extend</span></tt> keyword in the
<ttclass="descname">is_gray</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.colors.Colormap.is_gray" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.Colormap.set_bad">
<ttclass="descname">set_bad</tt><big>(</big><em>color='k'</em>, <em>alpha=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Colormap.set_bad" title="Permalink to this definition">¶</a></dt>
<dd><p>Set color to be used for masked values.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.Colormap.set_over">
<ttclass="descname">set_over</tt><big>(</big><em>color='k'</em>, <em>alpha=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Colormap.set_over" title="Permalink to this definition">¶</a></dt>
<dd><p>Set color to be used for high out-of-range values.
Requires norm.clip = False</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.Colormap.set_under">
<ttclass="descname">set_under</tt><big>(</big><em>color='k'</em>, <em>alpha=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Colormap.set_under" title="Permalink to this definition">¶</a></dt>
<dd><p>Set color to be used for low out-of-range values.
Requires norm.clip = False</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.LightSource">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">LightSource</tt><big>(</big><em>azdeg=315</em>, <em>altdeg=45</em>, <em>hsv_min_val=0</em>, <em>hsv_max_val=1</em>, <em>hsv_min_sat=1</em>, <em>hsv_max_sat=0</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LightSource" title="Permalink to this definition">¶</a></dt>
<p>Create a light source coming from the specified azimuth and elevation.
Angles are in degrees, with the azimuth measured
clockwise from north and elevation up from the zero plane of the surface.
The <aclass="reference internal" href="#matplotlib.colors.LightSource.shade" title="matplotlib.colors.LightSource.shade"><ttclass="xref py py-meth docutils literal"><spanclass="pre">shade()</span></tt></a> is used to produce rgb values for a shaded relief image
given a data array.</p>
<p>Specify the azimuth (measured clockwise from south) and altitude
(measured up from the plane of the surface) of the light source
in degrees.</p>
<p>The color of the resulting image will be darkened
by moving the (s,v) values (in hsv colorspace) toward
(hsv_min_sat, hsv_min_val) in the shaded regions, or
lightened by sliding (s,v) toward
(hsv_max_sat hsv_max_val) in regions that are illuminated.
The default extremes are chose so that completely shaded points
are nearly black (s = 1, v = 0) and completely illuminated points
are nearly white (s = 0, v = 1).</p>
<dlclass="method">
<dtid="matplotlib.colors.LightSource.shade">
<ttclass="descname">shade</tt><big>(</big><em>data</em>, <em>cmap</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LightSource.shade" title="Permalink to this definition">¶</a></dt>
<dd><p>Take the input data array, convert to HSV values in the
given colormap, then adjust those color values
to given the impression of a shaded relief map with a
specified light source.
RGBA values are returned, which can then be used to
plot the shaded image with imshow.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.LightSource.shade_rgb">
<ttclass="descname">shade_rgb</tt><big>(</big><em>rgb</em>, <em>elevation</em>, <em>fraction=1.0</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LightSource.shade_rgb" title="Permalink to this definition">¶</a></dt>
<dd><p>Take the input RGB array (ny*nx*3) adjust their color values
to given the impression of a shaded relief map with a
specified light source using the elevation (ny*nx).
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">LinearSegmentedColormap</tt><big>(</big><em>name</em>, <em>segmentdata</em>, <em>N=256</em>, <em>gamma=1.0</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LinearSegmentedColormap" title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><ttclass="descname">from_list</tt><big>(</big><em>name</em>, <em>colors</em>, <em>N=256</em>, <em>gamma=1.0</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LinearSegmentedColormap.from_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Make a linear segmented colormap with <em>name</em> from a sequence
of <em>colors</em> which evenly transitions from colors[0] at val=0
to colors[-1] at val=1. <em>N</em> is the number of rgb quantization
levels.
Alternatively, a list of (value, color) tuples can be given
<ttclass="descname">set_gamma</tt><big>(</big><em>gamma</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LinearSegmentedColormap.set_gamma" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a new gamma value and regenerate color map.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.ListedColormap">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">ListedColormap</tt><big>(</big><em>colors</em>, <em>name='from_list'</em>, <em>N=None</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.ListedColormap" title="Permalink to this definition">¶</a></dt>
<pclass="last">the list will be extended by repetition.</p>
</dd>
</dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.LogNorm">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">LogNorm</tt><big>(</big><em>vmin=None</em>, <em>vmax=None</em>, <em>clip=False</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LogNorm" title="Permalink to this definition">¶</a></dt>
<p>Works with scalars or arrays, including masked arrays. If
<em>clip</em> is <em>True</em>, masked values are set to 1; otherwise they
remain masked. Clipping silently defeats the purpose of setting
the over, under, and masked colors in the colormap, so it is
likely to lead to surprises; therefore the default is
<em>clip</em> = <em>False</em>.</p>
<dlclass="method">
<dtid="matplotlib.colors.LogNorm.autoscale">
<ttclass="descname">autoscale</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LogNorm.autoscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Set <em>vmin</em>, <em>vmax</em> to min, max of <em>A</em>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.LogNorm.autoscale_None">
<ttclass="descname">autoscale_None</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LogNorm.autoscale_None" title="Permalink to this definition">¶</a></dt>
<dd><p>autoscale only None-valued vmin or vmax</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.LogNorm.inverse">
<ttclass="descname">inverse</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.LogNorm.inverse" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.NoNorm">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">NoNorm</tt><big>(</big><em>vmin=None</em>, <em>vmax=None</em>, <em>clip=False</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.NoNorm" title="Permalink to this definition">¶</a></dt>
<p>Works with scalars or arrays, including masked arrays. If
<em>clip</em> is <em>True</em>, masked values are set to 1; otherwise they
remain masked. Clipping silently defeats the purpose of setting
the over, under, and masked colors in the colormap, so it is
likely to lead to surprises; therefore the default is
<em>clip</em> = <em>False</em>.</p>
<dlclass="method">
<dtid="matplotlib.colors.NoNorm.inverse">
<ttclass="descname">inverse</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.NoNorm.inverse" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.Normalize">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">Normalize</tt><big>(</big><em>vmin=None</em>, <em>vmax=None</em>, <em>clip=False</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize" title="Permalink to this definition">¶</a></dt>
<p>Works with scalars or arrays, including masked arrays. If
<em>clip</em> is <em>True</em>, masked values are set to 1; otherwise they
remain masked. Clipping silently defeats the purpose of setting
the over, under, and masked colors in the colormap, so it is
likely to lead to surprises; therefore the default is
<em>clip</em> = <em>False</em>.</p>
<dlclass="method">
<dtid="matplotlib.colors.Normalize.autoscale">
<ttclass="descname">autoscale</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize.autoscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Set <em>vmin</em>, <em>vmax</em> to min, max of <em>A</em>.</p>
<ttclass="descname">autoscale_None</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize.autoscale_None" title="Permalink to this definition">¶</a></dt>
<dd><p>autoscale only None-valued vmin or vmax</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.Normalize.inverse">
<ttclass="descname">inverse</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize.inverse" title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><ttclass="descname">process_value</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize.process_value" title="Permalink to this definition">¶</a></dt>
<dd><p>Homogenize the input <em>value</em> for easy and efficient normalization.</p>
<p><em>value</em> can be a scalar or sequence.</p>
<p>Returns <em>result</em>, <em>is_scalar</em>, where <em>result</em> is a
masked array matching <em>value</em>. Float dtypes are preserved;
integer types with two bytes or smaller are converted to
np.float32, and larger types are converted to np.float.
Preserving float32 when possible, and using in-place operations,
can greatly improve speed for large arrays.</p>
<p>Experimental; we may want to add an option to force the
use of float32.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.Normalize.scaled">
<ttclass="descname">scaled</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.colors.Normalize.scaled" title="Permalink to this definition">¶</a></dt>
<dd><p>return true if vmin and vmax set</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.colors.SymLogNorm">
<emclass="property">class </em><ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">SymLogNorm</tt><big>(</big><em>linthresh</em>, <em>linscale=1.0</em>, <em>vmin=None</em>, <em>vmax=None</em>, <em>clip=False</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.SymLogNorm" title="Permalink to this definition">¶</a></dt>
<p>The symmetrical logarithmic scale is logarithmic in both the
positive and negative directions from the origin.</p>
<p>Since the values close to zero tend toward infinity, there is a
need to have a range around zero that is linear. The parameter
<em>linthresh</em> allows the user to specify the size of this range
(-<em>linthresh</em>, <em>linthresh</em>).</p>
<p><em>linthresh</em>:
The range within which the plot is linear (to
avoid having the plot go to infinity around zero).</p>
<p><em>linscale</em>:
This allows the linear range (-<em>linthresh</em> to <em>linthresh</em>)
to be stretched relative to the logarithmic range. Its
value is the number of decades to use for each half of the
linear range. For example, when <em>linscale</em> == 1.0 (the
default), the space used for the positive and negative
halves of the linear range will be equal to one decade in
the logarithmic range. Defaults to 1.</p>
<dlclass="method">
<dtid="matplotlib.colors.SymLogNorm.autoscale">
<ttclass="descname">autoscale</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.SymLogNorm.autoscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Set <em>vmin</em>, <em>vmax</em> to min, max of <em>A</em>.</p>
<ttclass="descname">autoscale_None</tt><big>(</big><em>A</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.SymLogNorm.autoscale_None" title="Permalink to this definition">¶</a></dt>
<dd><p>autoscale only None-valued vmin or vmax</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colors.SymLogNorm.inverse">
<ttclass="descname">inverse</tt><big>(</big><em>value</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.SymLogNorm.inverse" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.from_levels_and_colors">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">from_levels_and_colors</tt><big>(</big><em>levels</em>, <em>colors</em>, <em>extend='neither'</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.from_levels_and_colors" title="Permalink to this definition">¶</a></dt>
<dd><p>A helper routine to generate a cmap and a norm instance which
behave similar to contourf’s levels and colors arguments.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><pclass="first"><strong>levels</strong> : sequence of numbers</p>
<blockquote>
<div><p>The quantization levels used to construct the <aclass="reference internal" href="#matplotlib.colors.BoundaryNorm" title="matplotlib.colors.BoundaryNorm"><ttclass="xref py py-class docutils literal"><spanclass="pre">BoundaryNorm</span></tt></a>.
Values <ttclass="docutils literal"><spanclass="pre">v</span></tt> are quantizized to level <ttclass="docutils literal"><spanclass="pre">i</span></tt> if
<p><strong>colors</strong> : sequence of colors</p>
<blockquote>
<div><p>The fill color to use for each level. If <ttclass="xref py py-obj docutils literal"><spanclass="pre">extend</span></tt> is “neither” there
must be <ttclass="docutils literal"><spanclass="pre">n_level</span><spanclass="pre">-</span><spanclass="pre">1</span></tt> colors. For an <ttclass="xref py py-obj docutils literal"><spanclass="pre">extend</span></tt> of “min” or “max” add
one extra color, and for an <ttclass="xref py py-obj docutils literal"><spanclass="pre">extend</span></tt> of “both” add two colors.</p>
<div><p>The behaviour when a value falls out of range of the given levels.
See <aclass="reference internal" href="pyplot_api.html#matplotlib.pyplot.contourf" title="matplotlib.pyplot.contourf"><ttclass="xref py py-func docutils literal"><spanclass="pre">contourf()</span></tt></a> for details.</p>
</div></blockquote>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first last"><strong>(cmap, norm)</strong> : tuple containing a <aclass="reference internal" href="#matplotlib.colors.Colormap" title="matplotlib.colors.Colormap"><ttclass="xref py py-class docutils literal"><spanclass="pre">Colormap</span></tt></a> and a <aclass="reference internal" href="#matplotlib.colors.Normalize" title="matplotlib.colors.Normalize"><ttclass="xref py py-class docutils literal"><spanclass="pre">Normalize</span></tt></a> instance</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.hex2color">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">hex2color</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.hex2color" title="Permalink to this definition">¶</a></dt>
<dd><p>Take a hex string <em>s</em> and return the corresponding rgb 3-tuple
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">hsv_to_rgb</tt><big>(</big><em>hsv</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.hsv_to_rgb" title="Permalink to this definition">¶</a></dt>
<dd><p>convert hsv values in a numpy array to rgb values
both input and output arrays have shape (M,N,3)</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.is_color_like">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">is_color_like</tt><big>(</big><em>c</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.is_color_like" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <em>True</em> if <em>c</em> can be converted to <em>RGB</em></p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.makeMappingArray">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">makeMappingArray</tt><big>(</big><em>N</em>, <em>data</em>, <em>gamma=1.0</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.makeMappingArray" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an <em>N</em> -element 1-d lookup table</p>
<p><em>data</em> represented by a list of x,y0,y1 mapping correspondences.
Each element in this list represents how a value between 0 and 1
(inclusive) represented by x is mapped to a corresponding value
between 0 and 1 (inclusive). The two values of y are to allow
for discontinuous mapping functions (say as might be found in a
sawtooth) where y0 represents the value of y for values of x
<= to that given, and y1 is the value to be used for x > than
that given). The list must start with x=0, end with x=1, and
all values of x must be in increasing order. Values between
the given mapping points are determined by simple linear interpolation.</p>
<p>Alternatively, data can be a function mapping values between 0 - 1
to 0 - 1.</p>
<p>The function returns an array “result” where <ttclass="docutils literal"><spanclass="pre">result[x*(N-1)]</span></tt>
gives the closest value for values of x between 0 and 1.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.no_norm">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">no_norm</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.no_norm" title="Permalink to this definition">¶</a></dt>
<dd><divclass="deprecated">
<p><span>Deprecated since version 1.3: </span>The no_norm class alias was deprecated in version 1.3. Use NoNorm instead.</p>
</div>
<p>Dummy replacement for Normalize, for the case where we
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">normalize</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.normalize" title="Permalink to this definition">¶</a></dt>
<dd><divclass="deprecated">
<p><span>Deprecated since version 1.3: </span>The normalize class alias was deprecated in version 1.3. Use Normalize instead.</p>
</div>
<p>A class which, when called, can normalize data into
the <ttclass="docutils literal"><spanclass="pre">[0.0,</span><spanclass="pre">1.0]</span></tt> interval.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.rgb2hex">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">rgb2hex</tt><big>(</big><em>rgb</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.rgb2hex" title="Permalink to this definition">¶</a></dt>
<dd><p>Given an rgb or rgba sequence of 0-1 floats, return the hex string</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colors.rgb_to_hsv">
<ttclass="descclassname">matplotlib.colors.</tt><ttclass="descname">rgb_to_hsv</tt><big>(</big><em>arr</em><big>)</big><aclass="headerlink" href="#matplotlib.colors.rgb_to_hsv" title="Permalink to this definition">¶</a></dt>
<dd><p>convert rgb values in a numpy array to hsv values
input and output arrays should have shape (M,N,3)</p>