Closed
Description
Bug report
After setting alpha to legend Patch, the color of edited patch resets to default(blue).
Code for reproduction
"""
========
Barchart
========
A bar plot with errorbars and height labels on individual bars
"""
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()
Actual outcome
Expected outcome
Matplotlib version
- Matplotlib version: 2.1.2
- Python version: 2.7