<!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>cm (colormap) — 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="The Matplotlib API" href="index.html" /> <link rel="next" title="collections" href="collections_api.html" /> <link rel="prev" title="cbook" href="cbook_api.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="collections_api.html" title="collections" accesskey="N">next</a> |</li> <li class="right" > <a href="cbook_api.html" title="cbook" 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">The Matplotlib API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">cm (colormap)</a><ul> <li><a class="reference internal" href="#module-matplotlib.cm"><tt class="docutils literal"><span class="pre">matplotlib.cm</span></tt></a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="cbook_api.html" title="previous chapter">cbook</a></p> <h4>Next topic</h4> <p class="topless"><a href="collections_api.html" title="next chapter">collections</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/api/cm_api.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="cm-colormap"> <h1>cm (colormap)<a class="headerlink" href="#cm-colormap" title="Permalink to this headline">¶</a></h1> <div class="section" id="module-matplotlib.cm"> <span id="matplotlib-cm"></span><h2><a class="reference internal" href="#module-matplotlib.cm" title="matplotlib.cm"><tt class="xref py py-mod docutils literal"><span class="pre">matplotlib.cm</span></tt></a><a class="headerlink" href="#module-matplotlib.cm" title="Permalink to this headline">¶</a></h2> <p>This module provides a large set of colormaps, functions for registering new colormaps and for getting a colormap by name, and a mixin class for adding color mapping functionality.</p> <dl class="class"> <dt id="matplotlib.cm.ScalarMappable"> <em class="property">class </em><tt class="descclassname">matplotlib.cm.</tt><tt class="descname">ScalarMappable</tt><big>(</big><em>norm=None</em>, <em>cmap=None</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable" title="Permalink to this definition">¶</a></dt> <dd><p>This is a mixin class to support scalar -> RGBA mapping. Handles normalization and colormapping</p> <p><em>norm</em> is an instance of <tt class="xref py py-class docutils literal"><span class="pre">colors.Normalize</span></tt> or one of its subclasses, used to map luminance to 0-1. <em>cmap</em> is a <tt class="xref py py-mod docutils literal"><span class="pre">cm</span></tt> colormap instance, for example <tt class="xref py py-data docutils literal"><span class="pre">cm.jet</span></tt></p> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.add_checker"> <tt class="descname">add_checker</tt><big>(</big><em>checker</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.add_checker" title="Permalink to this definition">¶</a></dt> <dd><p>Add an entry to a dictionary of boolean flags that are set to True when the mappable is changed.</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.autoscale"> <tt class="descname">autoscale</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.autoscale" title="Permalink to this definition">¶</a></dt> <dd><p>Autoscale the scalar limits on the norm instance using the current array</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.autoscale_None"> <tt class="descname">autoscale_None</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.autoscale_None" title="Permalink to this definition">¶</a></dt> <dd><p>Autoscale the scalar limits on the norm instance using the current array, changing only limits that are None</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.changed"> <tt class="descname">changed</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.changed" title="Permalink to this definition">¶</a></dt> <dd><p>Call this whenever the mappable is changed to notify all the callbackSM listeners to the ‘changed’ signal</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.check_update"> <tt class="descname">check_update</tt><big>(</big><em>checker</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.check_update" title="Permalink to this definition">¶</a></dt> <dd><p>If mappable has changed since the last check, return True; else return False</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.get_array"> <tt class="descname">get_array</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.get_array" title="Permalink to this definition">¶</a></dt> <dd><p>Return the array</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.get_clim"> <tt class="descname">get_clim</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.get_clim" title="Permalink to this definition">¶</a></dt> <dd><p>return the min, max of the color limits for image scaling</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.get_cmap"> <tt class="descname">get_cmap</tt><big>(</big><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.get_cmap" title="Permalink to this definition">¶</a></dt> <dd><p>return the colormap</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.set_array"> <tt class="descname">set_array</tt><big>(</big><em>A</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.set_array" title="Permalink to this definition">¶</a></dt> <dd><p>Set the image array from numpy array <em>A</em></p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.set_clim"> <tt class="descname">set_clim</tt><big>(</big><em>vmin=None</em>, <em>vmax=None</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.set_clim" title="Permalink to this definition">¶</a></dt> <dd><p>set the norm limits for image scaling; if <em>vmin</em> is a length2 sequence, interpret it as <tt class="docutils literal"><span class="pre">(vmin,</span> <span class="pre">vmax)</span></tt> which is used to support setp</p> <p>ACCEPTS: a length 2 sequence of floats</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.set_cmap"> <tt class="descname">set_cmap</tt><big>(</big><em>cmap</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.set_cmap" title="Permalink to this definition">¶</a></dt> <dd><p>set the colormap for luminance data</p> <p>ACCEPTS: a colormap or registered colormap name</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.set_colorbar"> <tt class="descname">set_colorbar</tt><big>(</big><em>im</em>, <em>ax</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.set_colorbar" title="Permalink to this definition">¶</a></dt> <dd><p>set the colorbar image and axes associated with mappable</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.set_norm"> <tt class="descname">set_norm</tt><big>(</big><em>norm</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.set_norm" title="Permalink to this definition">¶</a></dt> <dd><p>set the normalization instance</p> </dd></dl> <dl class="method"> <dt id="matplotlib.cm.ScalarMappable.to_rgba"> <tt class="descname">to_rgba</tt><big>(</big><em>x</em>, <em>alpha=None</em>, <em>bytes=False</em><big>)</big><a class="headerlink" href="#matplotlib.cm.ScalarMappable.to_rgba" title="Permalink to this definition">¶</a></dt> <dd><p>Return a normalized rgba array corresponding to <em>x</em>. If <em>x</em> is already an rgb array, insert <em>alpha</em>; if it is already rgba, return it unchanged. If <em>bytes</em> is True, return rgba as 4 uint8s instead of 4 floats.</p> </dd></dl> </dd></dl> <dl class="function"> <dt id="matplotlib.cm.get_cmap"> <tt class="descclassname">matplotlib.cm.</tt><tt class="descname">get_cmap</tt><big>(</big><em>name=None</em>, <em>lut=None</em><big>)</big><a class="headerlink" href="#matplotlib.cm.get_cmap" title="Permalink to this definition">¶</a></dt> <dd><p>Get a colormap instance, defaulting to rc values if <em>name</em> is None.</p> <p>Colormaps added with <a class="reference internal" href="#matplotlib.cm.register_cmap" title="matplotlib.cm.register_cmap"><tt class="xref py py-func docutils literal"><span class="pre">register_cmap()</span></tt></a> take precedence over builtin colormaps.</p> <p>If <em>name</em> is a <tt class="xref py py-class docutils literal"><span class="pre">colors.Colormap</span></tt> instance, it will be returned.</p> <p>If <em>lut</em> is not None it must be an integer giving the number of entries desired in the lookup table, and <em>name</em> must be a standard mpl colormap name with a corresponding data dictionary in <em>datad</em>.</p> </dd></dl> <dl class="function"> <dt id="matplotlib.cm.register_cmap"> <tt class="descclassname">matplotlib.cm.</tt><tt class="descname">register_cmap</tt><big>(</big><em>name=None</em>, <em>cmap=None</em>, <em>data=None</em>, <em>lut=None</em><big>)</big><a class="headerlink" href="#matplotlib.cm.register_cmap" title="Permalink to this definition">¶</a></dt> <dd><p>Add a colormap to the set recognized by <a class="reference internal" href="#matplotlib.cm.get_cmap" title="matplotlib.cm.get_cmap"><tt class="xref py py-func docutils literal"><span class="pre">get_cmap()</span></tt></a>.</p> <p>It can be used in two ways:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">register_cmap</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">'swirly'</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="n">swirly_cmap</span><span class="p">)</span> <span class="n">register_cmap</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s">'choppy'</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">choppydata</span><span class="p">,</span> <span class="n">lut</span><span class="o">=</span><span class="mi">128</span><span class="p">)</span> </pre></div> </div> <p>In the first case, <em>cmap</em> must be a <tt class="xref py py-class docutils literal"><span class="pre">colors.Colormap</span></tt> instance. The <em>name</em> is optional; if absent, the name will be the <tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt> attribute of the <em>cmap</em>.</p> <p>In the second case, the three arguments are passed to the <tt class="xref py py-class docutils literal"><span class="pre">colors.LinearSegmentedColormap</span></tt> initializer, and the resulting colormap is registered.</p> </dd></dl> <dl class="function"> <dt id="matplotlib.cm.revcmap"> <tt class="descclassname">matplotlib.cm.</tt><tt class="descname">revcmap</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#matplotlib.cm.revcmap" title="Permalink to this definition">¶</a></dt> <dd><p>Can only handle specification <em>data</em> in dictionary format.</p> </dd></dl> </div> </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="collections_api.html" title="collections" >next</a> |</li> <li class="right" > <a href="cbook_api.html" title="cbook" >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" >The Matplotlib API</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>