<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>

<p dir="auto">HEX code passed to the <code class="notranslate">color</code> parameter of any Pyplot plots/patches/fills results in incorrect color being rendered.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from matplotlib import pyplot as plt
plt.fill_between([0,1],[0,0],[1,1], color='#7818FE')
plt.show()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">import</span> <span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-s1">plt</span>.<span class="pl-en">fill_between</span>([<span class="pl-c1">0</span>,<span class="pl-c1">1</span>],[<span class="pl-c1">0</span>,<span class="pl-c1">0</span>],[<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'#7818FE'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>

<p dir="auto">Rather than '#7818FE', '#601BFE' is being output. Similarly, plotting '#CCCCCC' results in '#BEBDBE' instead.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/21b27e6bf0fe19593f5bba1477a0edf6df958e2f33170eb324130ffbf8c66ef8/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f7a78664c662e706e67"><img src="https://camo.githubusercontent.com/21b27e6bf0fe19593f5bba1477a0edf6df958e2f33170eb324130ffbf8c66ef8/68747470733a2f2f692e737461636b2e696d6775722e636f6d2f7a78664c662e706e67" alt="Matplotlib displays incorrect color" data-canonical-src="https://i.stack.imgur.com/zxfLf.png" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>


<p dir="auto">Expects identical color to be output. I don't think this is simply compression artefact, because I have tried to save it as PNG and still the colors are (way) off. Color space issue maybe?</p>
<p dir="auto">This issue matters because our team has to draw infographics exactly as specified by our designers, and the colors are so wrong that even a red-green color-blind team member can tell the difference between the incorrect colors, in shades of red/green, visually...</p>
<p dir="auto">The issue is so glaringly obvious that I expect it to have been asked before, but I can't seem to find any previous issue. If this is a duplicate I apologize.</p>
<p dir="auto">I have asked this same question on <a href="https://stackoverflow.com/questions/53188405/matplotlib-draws-incorrect-color" rel="nofollow">Stack Overflow</a>.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: macOS High Sierra 10.13.6</li>
<li>Matplotlib version: 3.0.0, installed from pip</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): module://ipykernel.pylab.backend_inline</li>
<li>Python version: 3.6.5</li>
<li>Jupyter version (if applicable): 1.0.0 (same issue also happen with good-ol' .py outside Jupyter)</li>
<li>Other libraries:</li>
</ul>
<h3 dir="auto">Bug summary</h3>
<p dir="auto">matplotlib.set_loglevel() adds a <code class="notranslate">logging</code> console handler which then leads to duplicate messages in application code. The best practice is to allow the application code to add the handlers to its logger along with formatting, filtering, etc. The existing <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="401954424" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/13264" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/13264/hovercard" href="https://github.com/matplotlib/matplotlib/issues/13264">#13264</a> attempted to address this.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import logging
import matplotlib as mpl
mpl_logger = logging.getLogger(&quot;matplotlib&quot;)
mpl.set_loglevel(&quot;debug&quot;)
mpl_logger.hasHandlers()
logger = logging.getLogger()
ch = logging.StreamHandler()
logger.addHandler(ch)
logger.setLevel(logging.DEBUG)
import matplotlib.pyplot as plt"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">logging</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">as</span> <span class="pl-s1">mpl</span>
<span class="pl-s1">mpl_logger</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>(<span class="pl-s">"matplotlib"</span>)
<span class="pl-s1">mpl</span>.<span class="pl-en">set_loglevel</span>(<span class="pl-s">"debug"</span>)
<span class="pl-s1">mpl_logger</span>.<span class="pl-en">hasHandlers</span>()
<span class="pl-s1">logger</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>()
<span class="pl-s1">ch</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-v">StreamHandler</span>()
<span class="pl-s1">logger</span>.<span class="pl-en">addHandler</span>(<span class="pl-s1">ch</span>)
<span class="pl-s1">logger</span>.<span class="pl-en">setLevel</span>(<span class="pl-s1">logging</span>.<span class="pl-v">DEBUG</span>)
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span></pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">True<br>
DEBUG:matplotlib:CACHEDIR=C:\Users\ljohnsto.matplotlib<br>
CACHEDIR=C:\Users\ljohnsto.matplotlib<br>
DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\ljohnsto.matplotlib\fontlist-v330.json<br>
Using fontManager instance from C:\Users\ljohnsto.matplotlib\fontlist-v330.json</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">False<br>
CACHEDIR=C:\Users\ljohnsto.matplotlib<br>
Using fontManager instance from C:\Users\ljohnsto.matplotlib\fontlist-v330.json</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">The workaround is:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [1]: import logging
In [2]: import matplotlib as mpl
In [3]: mpl_logger = logging.getLogger(&quot;matplotlib&quot;)
In [4]: mpl.set_loglevel(&quot;debug&quot;)
In [5]: mpl_logger_handlers = mpl_logger.handlers.copy()
In [6]: for h in mpl_logger_handlers:
   ...:     mpl_logger.removeHandler(h)
   ...:
In [7]: logger = logging.getLogger()
In [8]: ch = logging.StreamHandler()
In [9]: logger.addHandler(ch)
In [10]: logger.setLevel(logging.DEBUG)
In [11]: import matplotlib.pyplot as plt
CACHEDIR=C:\Users\ljohnsto\.matplotlib
Using fontManager instance from C:\Users\ljohnsto\.matplotlib\fontlist-v330.json
'''

### Operating system

Windows

### Matplotlib Version

3.5.2

### Matplotlib Backend

TkAgg

### Python version

3.9.13

### Jupyter version

_No response_

### Installation

pip"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">1</span>]: <span class="pl-s1">import</span> <span class="pl-s1">logging</span>
<span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-s1">import</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">as</span> <span class="pl-s1">mpl</span>
<span class="pl-v">In</span> [<span class="pl-c1">3</span>]: <span class="pl-s1">mpl_logger</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>(<span class="pl-s">"matplotlib"</span>)
<span class="pl-v">In</span> [<span class="pl-c1">4</span>]: <span class="pl-s1">mpl</span>.<span class="pl-en">set_loglevel</span>(<span class="pl-s">"debug"</span>)
<span class="pl-v">In</span> [<span class="pl-c1">5</span>]: <span class="pl-s1">mpl_logger_handlers</span> <span class="pl-c1">=</span> <span class="pl-s1">mpl_logger</span>.<span class="pl-s1">handlers</span>.<span class="pl-en">copy</span>()
<span class="pl-v">In</span> [<span class="pl-c1">6</span>]: <span class="pl-s1">for</span> <span class="pl-s1">h</span> <span class="pl-c1">in</span> <span class="pl-s1">mpl_logger_handlers</span>:
   ...:     <span class="pl-s1">mpl_logger</span>.<span class="pl-en">removeHandler</span>(<span class="pl-s1">h</span>)
   ...:
<span class="pl-v">In</span> [<span class="pl-c1">7</span>]: <span class="pl-s1">logger</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-en">getLogger</span>()
<span class="pl-v">In</span> [<span class="pl-c1">8</span>]: <span class="pl-s1">ch</span> <span class="pl-c1">=</span> <span class="pl-s1">logging</span>.<span class="pl-v">StreamHandler</span>()
<span class="pl-v">In</span> [<span class="pl-c1">9</span>]: <span class="pl-s1">logger</span>.<span class="pl-en">addHandler</span>(<span class="pl-s1">ch</span>)
<span class="pl-v">In</span> [<span class="pl-c1">10</span>]: <span class="pl-s1">logger</span>.<span class="pl-en">setLevel</span>(<span class="pl-s1">logging</span>.<span class="pl-v">DEBUG</span>)
<span class="pl-v">In</span> [<span class="pl-c1">11</span>]: <span class="pl-s1">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-v">CACHEDIR</span><span class="pl-c1">=</span><span class="pl-v">C</span>:\U<span class="pl-s1">sers</span>\l<span class="pl-s1">johnsto</span>\.<span class="pl-s1">matplotlib</span>
<span class="pl-v">Using</span> <span class="pl-s1">fontManager</span> <span class="pl-s1">instance</span> <span class="pl-s1">from</span> <span class="pl-v">C</span>:\U<span class="pl-s1">sers</span>\l<span class="pl-s1">johnsto</span>\.<span class="pl-s1">matplotlib</span>\f<span class="pl-s1">ontlist</span><span class="pl-c1">-</span><span class="pl-s1">v330</span>.<span class="pl-s1">json</span>
'''

<span class="pl-c">### Operating system</span>

<span class="pl-v">Windows</span>

<span class="pl-c">### Matplotlib Version</span>

<span class="pl-c1">3.5</span>.<span class="pl-c1">2</span>

<span class="pl-c">### Matplotlib Backend</span>

<span class="pl-v">TkAgg</span>

<span class="pl-c">### Python version</span>

<span class="pl-c1">3.9</span>.<span class="pl-c1">13</span>

<span class="pl-c">### Jupyter version</span>

<span class="pl-s1">_No</span> <span class="pl-s1">response_</span>

<span class="pl-c">### Installation</span>

<span class="pl-s1">pip</span></pre></div>