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
[ENH]: Add a HandlerFancyArrowPatch to the list of default legend_handlers #32708
We've recently run into an application in NetworkX that got me wondering whether it might make sense to upstream a legend handler - so I figured I'd ask! FWIW I scrolled through the mpl issue tracker to see if this had been requested before. AFAICT there haven't been any specific requests along these lines, but apologies if I missed them.
Motivation
NetworkX uses FancyArrowPatches to represent edges when visualizing directed graphs. We recently had an issue where users noticed that directed edges were not being added to the legend. The initial fix was to create proxy Line2D objects and use them to populate the default legend: see networkx/networkx#8951.
This works great, but the one issue is Line2D doesn't capture the arrowstyle in the legend. I was able to find a solution in the legend_handler documentation (which was very nice + discoverable, BTW!) which provided a straightforward recipe for doing exactly what we needed: see networkx/networkx#9069
This got me thinking whether or not other users might benefit from having a HandlerFancyArrowPatch available by default in matplotlib to properly capture/render arrowstyles in the legend. It would certainly be useful for NetworkX (we could essentially do away with networkx/networkx@501f209). LMK what you think!
Activity
story645 commentedon Dec 2, 2026
I'm for it and looks like #10688 got most of the way there
rossbar commentedon Dec 3, 2026
For potential reviewers - FWIW I'm working on a (non-AI) PR now that preserves attribution from #10688