Skip to content

[ENH]: Add a HandlerFancyArrowPatch to the list of default legend_handlers #32708

In review

Description

@rossbar

Problem

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!

Proposed solution

No response

Activity

  1. story645 commented on Dec 2, 2026

    @story645
    Member

    I'm for it and looks like #10688 got most of the way there

  2. rossbar commented on Dec 3, 2026

    @rossbar
    Author

    For potential reviewers - FWIW I'm working on a (non-AI) PR now that preserves attribution from #10688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions