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
{{ message }}
Repository navigation
Setting alpha on legend handle changes patch color #11702
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 set_alpha on a legend handle, the color of the patch in the legend changes.
It looks like set_color() calls set_edgecolor() and set_facecolor(), which already update _original_edgecolor and _original_facecolor respectively.
Perhaps set_color() isn't getting called as the legend is being set up? I tried digging through the legend code, but I don't understand matplotlib's internals terribly well and got rather lost.
Activity
bpteague commentedon Jul 19, 2018
Seems related to the following lines in
matplotlib.patches.set_alpha:because both
self._original_facecolorandself._original_edgecolorare set toNone.jklymak commentedon Jul 19, 2018
Huh, I thought we squashed that bug. Anyway, the fix is to have the
_original_face/edgecolorsset inset_colorfew lines after. Want to make a PR?bpteague commentedon Jul 19, 2018
It looks like
set_color()callsset_edgecolor()andset_facecolor(), which already update_original_edgecolorand_original_facecolorrespectively.Perhaps
set_color()isn't getting called as the legend is being set up? I tried digging through the legend code, but I don't understandmatplotlib's internals terribly well and got rather lost.jklymak commentedon Jul 19, 2018
Ooops. Yes, you are right. Chasing through legend isn't pretty...
jklymak commentedon Jul 19, 2018
See #11703 - looks like it fixes the problem to me... Thanks for the great report.
bpteague commentedon Jul 19, 2018
Brilliant. #11703 fixes this for me too. Thanks for digging into this for me (-:
jklymak commentedon Jul 19, 2018
Ha we only get to close it when the PR gets merged 😉
bpteague commentedon Jul 19, 2018
I just got so excited! An hour from report to fix is pretty remarkable. Thanks again.
jklymak commentedon Jul 19, 2018
Well, I was annoyed, because I fixed that bug 6 months ago (for markers instead of bars)...
boyob commentedon Apr 3, 2019
How to change the color of font in legend?
timhoffm commentedon Apr 3, 2019
@boyob This is the bug tracker. For help, please use gitter, the mailinglist or stackoverflow. https://matplotlib.org/#need-help