Skip to content Skip to sidebar Skip to footer

Deleting Streamplots (matplotlib) Without Clearing The Graph

i've always found help here until now. i've been looking for a solution of my problem very long and i might be blind by now.. i hope you can help me with this one: i've built a pyt

Solution 1:

There is a workaround for PatchCollection not having a working remove method.

The arrows are added to ax.patches. Assuming you don't have any other patches in the plot (e.g. a bar plot uses patches), you can just do ax.patches = [] to remove the arrows.

Ideally, you'd get the patches from the sl.arrowsPatchCollection, but it doesn't actually store a reference to the patches themselves, just their raw paths.

If you do have other patches in the plot, you could remove all instances of FancyArrowPatch instead. E.g.

keep = lambda x: not isinstance(x, mpl.patches.FancyArrowPatch)
ax.patches = [patch for patch in ax.patches if keep(patch)]

Post a Comment for "Deleting Streamplots (matplotlib) Without Clearing The Graph"