Skip to content

PatchCollection doesn't properly handle FancyArrowPatch, breaking StreamplotSet.arrows #2341

Closed as not planned

Description

@cgevans

As discussed in this SO question and this mailing list thread, PatchCollection cannot handle FancyArrowPatch patches, as the paths for FancyArrowPatch can't be evaluated during PatchCollection creation. It appears that an issue was never created for this... please let me know if I'm being stupid and not noticing one.

As such, the StreamplotSet.arrows PatchCollection appears to be entirely useless. In fact, streamplot() doesn't even add the collection to the axis, instead adding the individual patches, and then creating an apparently unused PatchCollection to return. This means that things that should work, like, for a StreamplotSet s, doing s.arrows.set_visible(False), will not work, nor, to my knowledge, will doing anything with StreamplotSet.arrows have the desired result.

As discussed in the mailing list thread, one potential solution to this would be to create a FancyArrowPatchCollection class especially for FancyArrowPatch, and then use this for streamplot; someone in the thread also gives a rudimentary class. If I have time, I might try to implement this, but does anyone have any better ideas?

Activity

  1. tonysyu commented on Oct 6, 2013

    @tonysyu
    Contributor

    I'm guessing incompatibilities between FancyArrowPatch and PatchCollection was the reason the arrow collection is not added to axes. (To be honest, I don't remember.) I'm not sure what a full implementation of a FancyArrowPatchCollection would require, so I tried implementing a simpler fix using FancyArrow instead (See PR #2500).

  2. added this to the milestone on Aug 17, 2014
  3. tacaswell commented on Aug 17, 2014

    @tacaswell
    Member

    @cgevans Did you make any progress on this?

    @tonysyu Any interest in reviving #2500?

  4. petehuang commented on Dec 31, 2016

    @petehuang
    Contributor

    Confirming this is still an issue in 1.5.3

    import numpy as np
    import matplotlib.pyplot as plt
    
    w = 3
    Y, X = np.mgrid[-w:w:100j, -w:w:100j]
    U = -1 - X**2 + Y
    V = 1 + X - Y**2
    
    c = plt.streamplot(X, Y, U, V, color=(0,0,0,1))
    c.lines.set_alpha(0)
    c.arrows.set_alpha(0)
    plt.show()

    PR still welcome here, would recommend reading through #2500 despite it stalling.

    Recommend labeling with confirmed bug

  5. modified the milestones: , on Oct 3, 2017
  6. rodogi commented on Dec 13, 2017

    @rodogi

    Just to comment that fixing this bug will benefit networkx arrow-drawing (see here) as arrows are FancyArrowPatch instances.

  7. anntzer commented on Jan 20, 2021

    @anntzer
    Contributor

    I had a quick look at this. I think the solution likely involves using PatchCollection with TransformedPatchPath entries, so that the transform info stays in the collection. But additionally, the draw-time computation done in FancyArrowPatch will need to move from get_path_in_displaycoord to a custom transform subclass, which contains the relevant logic but will be able to be combined with other transforms); this is likely the trickier part.

  8. yves-surrel commented on Nov 7, 2021

    @yves-surrel

    Will this bug be ever fixed? I need to plot hundreds of annotations and it is awfully slow...

  9. github-actions commented on Mar 3, 2023

    @github-actions

    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!

  10. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
  11. robintheconqueror commented on Apr 2, 2024

    @robintheconqueror

    My some_streamplotset.arrows.remove() continues to fail... Any updates on this?

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions