Closed
Description
Bug summary
Bug #11702 seems to have reappeared: calling set_alpha on a legend handle causes the color of the patch in the legend to change in a filled area plot.
Code for reproduction
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({
'sales': [3, 2, 3],
'visits': [20, 42, 28],
'day': [1, 2, 3],
})
df.plot.area(x='day')
legend = plt.legend()
for p in legend.get_patches():
p.set_alpha(1)
Actual outcome
Expected outcome
The patch for 'visits' should be orange.
Additional information
This was working fine at least until mpl 3.3.4.
As for the previous workaround, calling set_facecolor(get_facecolor()) before calling set_alpha() works. I'm using legend.get_patches() here instead of iterating through the handles directly, but there's no difference.
Operating system
Linux (debian unstable)
Matplotlib Version
3.5.0
Matplotlib Backend
Qt5Agg or agg
Python version
3.9.9
Jupyter version
n/a
Installation
Linux package manager
Metadata
Metadata
Assignees
Labels
No labels