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
<liclass="toctree-l2"><aclass="reference internal" href="../introductory/lifecycle.html">The Lifecycle of a Plot</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../introductory/customizing.html">Customizing Matplotlib with style sheets and rcParams</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../introductory/animation_tutorial.html">Animations using Matplotlib</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../text/pgf.html">Text rendering with XeLaTeX/LuaLaTeX via the <codeclass="docutils literal notranslate"><spanclass="pre">pgf</span></code> backend</a></li>
<liclass="toctree-l2"><aclass="reference internal" href="../text/usetex.html">Text rendering with LaTeX</a></li>
<spanid="sphx-glr-tutorials-colors-colors-py"></span><h1>Specifying colors<aclass="headerlink" href="#specifying-colors" title="Permalink to this heading">#</a></h1>
<sectionid="color-formats">
<h2>Color formats<aclass="headerlink" href="#color-formats" title="Permalink to this heading">#</a></h2>
<p>Matplotlib recognizes the following formats to specify a color.</p>
<trclass="row-even"><td><p>Case-insensitive color name from
<aclass="reference external" href="https://xkcd.com/color/rgb/">xkcd color survey</a> with <codeclass="docutils literal notranslate"><spanclass="pre">'xkcd:'</span></code>
<imgsrc="../../_images/sphx_glr_colors_001.png" srcset="../../_images/sphx_glr_colors_001.png, ../../_images/sphx_glr_colors_001_2_0x.png 2.0x" alt="alpha values" class = "sphx-glr-single-img"/><p>The orange rectangle is semi-transparent with <em>alpha</em> = 0.8. The top row of
blue squares is drawn below and the bottom row of blue squares is drawn on
top of the orange rectangle.</p>
<p>See also <aclass="reference internal" href="../../gallery/misc/zorder_demo.html"><spanclass="doc">Zorder Demo</span></a> to learn more on the drawing order.</p>
</section>
<sectionid="cn-color-selection">
<h2>"CN" color selection<aclass="headerlink" href="#cn-color-selection" title="Permalink to this heading">#</a></h2>
<p>Matplotlib converts "CN" colors to RGBA when drawing Artists. The
<aclass="reference internal" href="../intermediate/color_cycle.html"><spanclass="doc">Styling with cycler</span></a> section contains additional
information about controlling colors and style properties.</p>
<li><imgsrc="../../_images/sphx_glr_colors_002.png" srcset="../../_images/sphx_glr_colors_002.png, ../../_images/sphx_glr_colors_002_2_0x.png 2.0x" alt="style: 'default'" class = "sphx-glr-multi-img"/></li>
<li><imgsrc="../../_images/sphx_glr_colors_003.png" srcset="../../_images/sphx_glr_colors_003.png, ../../_images/sphx_glr_colors_003_2_0x.png 2.0x" alt="style: 'seaborn-v0_8'" class = "sphx-glr-multi-img"/></li>
</ul>
<p>The first color <codeclass="docutils literal notranslate"><spanclass="pre">'C0'</span></code> is the title. Each plot uses the second and third
colors of each style's <codeclass="docutils literal notranslate"><aclass="reference internal" href="../introductory/customizing.html?highlight=axes.prop_cycle#matplotlibrc-sample"><spanclass="std std-ref"><spanclass="pre">rcParams["axes.prop_cycle"]</span></span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">cycler('color',</span><spanclass="pre">['#1f77b4',</span><spanclass="pre">'#ff7f0e',</span><spanclass="pre">'#2ca02c',</span><spanclass="pre">'#d62728',</span><spanclass="pre">'#9467bd',</span><spanclass="pre">'#8c564b',</span><spanclass="pre">'#e377c2',</span><spanclass="pre">'#7f7f7f',</span><spanclass="pre">'#bcbd22',</span><spanclass="pre">'#17becf'])</span></code>). They are <codeclass="docutils literal notranslate"><spanclass="pre">'C1'</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">'C2'</span></code>,
<spanid="xkcd-colors"></span><h2>Comparison between X11/CSS4 and xkcd colors<aclass="headerlink" href="#comparison-between-x11-css4-and-xkcd-colors" title="Permalink to this heading">#</a></h2>
<p>The xkcd colors come from a <aclass="reference external" href="https://blog.xkcd.com/2010/05/03/color-survey-results/">user survey conducted by the webcomic xkcd</a>.</p>
<p>95 out of the 148 X11/CSS4 color names also appear in the xkcd color survey.
Almost all of them map to different color values in the X11/CSS4 and in
the xkcd palette. Only 'black', 'white' and 'cyan' are identical.</p>
<p>For example, <codeclass="docutils literal notranslate"><spanclass="pre">'blue'</span></code> maps to <codeclass="docutils literal notranslate"><spanclass="pre">'#0000FF'</span></code> whereas <codeclass="docutils literal notranslate"><spanclass="pre">'xkcd:blue'</span></code> maps to
<codeclass="docutils literal notranslate"><spanclass="pre">'#0343DF'</span></code>. Due to these name collisions, all xkcd colors have the
<imgsrc="../../_images/sphx_glr_colors_004.png" srcset="../../_images/sphx_glr_colors_004.png, ../../_images/sphx_glr_colors_004_2_0x.png 2.0x" alt="colors" class = "sphx-glr-single-img"/><pclass="sphx-glr-timing"><strong>Total running time of the script:</strong> ( 0 minutes 1.586 seconds)</p>