<h3 dir="auto">Bug report</h3>
<p dir="auto">After setting alpha to legend Patch, the color of edited patch resets to default(blue).</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="&quot;&quot;&quot;
========
Barchart
========

A bar plot with errorbars and height labels on individual bars
&quot;&quot;&quot;
import matplotlib.pyplot as plt
import numpy as np

N = 5
men_means = (20, 35, 30, 35, 27)
men_std = (2, 3, 4, 1, 2)

ind = np.arange(N)  # the x locations for the groups
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(ind, men_means, width, color='r', yerr=men_std)

women_means = (25, 32, 34, 20, 25)
women_std = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind + width, women_means, width, color='y', yerr=women_std)

# add some text for labels, title and axes ticks
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width / 2)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))

leg = ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))

#this line causes bug - reset to default color(blue)
leg.get_patches()[0].set_alpha(0.854321)

plt.show()"><pre class="notranslate"><span class="pl-s">"""</span>
<span class="pl-s">========</span>
<span class="pl-s">Barchart</span>
<span class="pl-s">========</span>
<span class="pl-s"></span>
<span class="pl-s">A bar plot with errorbars and height labels on individual bars</span>
<span class="pl-s">"""</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>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">N</span> <span class="pl-c1">=</span> <span class="pl-c1">5</span>
<span class="pl-s1">men_means</span> <span class="pl-c1">=</span> (<span class="pl-c1">20</span>, <span class="pl-c1">35</span>, <span class="pl-c1">30</span>, <span class="pl-c1">35</span>, <span class="pl-c1">27</span>)
<span class="pl-s1">men_std</span> <span class="pl-c1">=</span> (<span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)

<span class="pl-s1">ind</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-v">N</span>)  <span class="pl-c"># the x locations for the groups</span>
<span class="pl-s1">width</span> <span class="pl-c1">=</span> <span class="pl-c1">0.35</span>  <span class="pl-c"># the width of the bars</span>

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-s1">rects1</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">bar</span>(<span class="pl-s1">ind</span>, <span class="pl-s1">men_means</span>, <span class="pl-s1">width</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'r'</span>, <span class="pl-s1">yerr</span><span class="pl-c1">=</span><span class="pl-s1">men_std</span>)

<span class="pl-s1">women_means</span> <span class="pl-c1">=</span> (<span class="pl-c1">25</span>, <span class="pl-c1">32</span>, <span class="pl-c1">34</span>, <span class="pl-c1">20</span>, <span class="pl-c1">25</span>)
<span class="pl-s1">women_std</span> <span class="pl-c1">=</span> (<span class="pl-c1">3</span>, <span class="pl-c1">5</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">3</span>)
<span class="pl-s1">rects2</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">bar</span>(<span class="pl-s1">ind</span> <span class="pl-c1">+</span> <span class="pl-s1">width</span>, <span class="pl-s1">women_means</span>, <span class="pl-s1">width</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s">'y'</span>, <span class="pl-s1">yerr</span><span class="pl-c1">=</span><span class="pl-s1">women_std</span>)

<span class="pl-c"># add some text for labels, title and axes ticks</span>
<span class="pl-s1">ax</span>.<span class="pl-en">set_ylabel</span>(<span class="pl-s">'Scores'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'Scores by group and gender'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_xticks</span>(<span class="pl-s1">ind</span> <span class="pl-c1">+</span> <span class="pl-s1">width</span> <span class="pl-c1">/</span> <span class="pl-c1">2</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_xticklabels</span>((<span class="pl-s">'G1'</span>, <span class="pl-s">'G2'</span>, <span class="pl-s">'G3'</span>, <span class="pl-s">'G4'</span>, <span class="pl-s">'G5'</span>))

<span class="pl-s1">leg</span> <span class="pl-c1">=</span> <span class="pl-s1">ax</span>.<span class="pl-en">legend</span>((<span class="pl-s1">rects1</span>[<span class="pl-c1">0</span>], <span class="pl-s1">rects2</span>[<span class="pl-c1">0</span>]), (<span class="pl-s">'Men'</span>, <span class="pl-s">'Women'</span>))

<span class="pl-c">#this line causes bug - reset to default color(blue)</span>
<span class="pl-s1">leg</span>.<span class="pl-en">get_patches</span>()[<span class="pl-c1">0</span>].<span class="pl-en">set_alpha</span>(<span class="pl-c1">0.854321</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16255826/36615032-17f0e40e-18df-11e8-86ad-6570e5f3745e.png"><img src="https://user-images.githubusercontent.com/16255826/36615032-17f0e40e-18df-11e8-86ad-6570e5f3745e.png" alt="obraz" style="max-width: 100%;"></a><br>
<strong>Expected outcome</strong><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16255826/36615150-930c4b1a-18df-11e8-8c90-567bd1e45b54.png"><img src="https://user-images.githubusercontent.com/16255826/36615150-930c4b1a-18df-11e8-8c90-567bd1e45b54.png" alt="obraz" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Matplotlib version: 2.1.2</li>
<li>Python version: 2.7</li>
</ul>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">I occasionally want the alpha value of the patch in a histogram's legend to be different than the alpha value used to plot the legend.  However, when I call <code class="notranslate">set_alpha</code> on a legend handle, the color of the patch in the legend changes.</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="import matplotlib.pyplot as plt

plt.hist([1, 2, 3], alpha = 0.25, label = 'data', color = 'red')
legend = plt.legend()
for lh in legend.legendHandles:
    lh.set_alpha(1.0)"><pre class="notranslate"><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>

<span class="pl-s1">plt</span>.<span class="pl-en">hist</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>], <span class="pl-s1">alpha</span> <span class="pl-c1">=</span> <span class="pl-c1">0.25</span>, <span class="pl-s1">label</span> <span class="pl-c1">=</span> <span class="pl-s">'data'</span>, <span class="pl-s1">color</span> <span class="pl-c1">=</span> <span class="pl-s">'red'</span>)
<span class="pl-s1">legend</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">legend</span>()
<span class="pl-k">for</span> <span class="pl-s1">lh</span> <span class="pl-c1">in</span> <span class="pl-s1">legend</span>.<span class="pl-s1">legendHandles</span>:
    <span class="pl-s1">lh</span>.<span class="pl-en">set_alpha</span>(<span class="pl-c1">1.0</span>)</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2431900/42916377-e3e2c770-8ad2-11e8-9a9d-77f0db02e7a2.png"><img src="https://user-images.githubusercontent.com/2431900/42916377-e3e2c770-8ad2-11e8-9a9d-77f0db02e7a2.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Work-around</strong></p>
<p dir="auto">I can get the result I desire if I call <code class="notranslate">set_edgecolor()</code> and <code class="notranslate">set_facecolor()</code>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="plt.hist([1, 2, 3], alpha = 0.25, label = 'data', color = 'red')
legend = plt.legend()
for lh in legend.legendHandles:
    lh.set_facecolor(lh.get_facecolor())
    lh.set_edgecolor(lh.get_edgecolor())
    lh.set_alpha(1.0)"><pre class="notranslate"><span class="pl-s1">plt</span>.<span class="pl-en">hist</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>], <span class="pl-s1">alpha</span> <span class="pl-c1">=</span> <span class="pl-c1">0.25</span>, <span class="pl-s1">label</span> <span class="pl-c1">=</span> <span class="pl-s">'data'</span>, <span class="pl-s1">color</span> <span class="pl-c1">=</span> <span class="pl-s">'red'</span>)
<span class="pl-s1">legend</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">legend</span>()
<span class="pl-k">for</span> <span class="pl-s1">lh</span> <span class="pl-c1">in</span> <span class="pl-s1">legend</span>.<span class="pl-s1">legendHandles</span>:
    <span class="pl-s1">lh</span>.<span class="pl-en">set_facecolor</span>(<span class="pl-s1">lh</span>.<span class="pl-en">get_facecolor</span>())
    <span class="pl-s1">lh</span>.<span class="pl-en">set_edgecolor</span>(<span class="pl-s1">lh</span>.<span class="pl-en">get_edgecolor</span>())
    <span class="pl-s1">lh</span>.<span class="pl-en">set_alpha</span>(<span class="pl-c1">1.0</span>)</pre></div>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2431900/42916427-26b11bd8-8ad3-11e8-8a68-d6fc1a08efeb.png"><img src="https://user-images.githubusercontent.com/2431900/42916427-26b11bd8-8ad3-11e8-8a68-d6fc1a08efeb.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Matplotlib v2.2.2</li>
<li>Installed from Anaconda (default channel)</li>
<li>Backend: module://ipykernel.pylab.backend_inline</li>
<li>Jupyter version: 5.5.0</li>
</ul>