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
Patches eagerly resolve colors and apply alpha, but should do so lazily like Line2Ds #11710
from matplotlib.pyplot import Line2D, Rectangle
l = Line2D([], [], alpha=.5)
l.set_color("red")
print(l.get_color())
r = Rectangle((0, 0), 1, 1, alpha=.5)
r.set_facecolor("red")
print(r.get_facecolor())
The line reports its color as "red", but the rectangle reports it as (1, 0, 0, .5). This is because patches immediately resolve colors and apply alphas; to do so they need to maintain an elaborate dance involving _original_facecolor and _original_edgecolor. Conversely, Line2D doesn't resolve colors eagerly (they just store whatever was passed in), and perform the conversion in draw().
This will draw a red line (draw-time resolution is affected by the new prop_cycle), but a blue rectangle (eager resolution uses the original prop_cycle).
I think the behavior of Line2D makes more sense (at least the output of get_facecolor() immediately after a set_facecolor() should be what we set...), this would also avoid issues such as #11702/#11703.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
github-actions commentedon May 9, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!