Skip to content

Commit

Permalink
Return arrow collection as 2nd argument of streamplot.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysyu committed Sep 2, 2012
1 parent cadd152 commit 391c24a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Expand Up @@ -3055,7 +3055,7 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
draw_if_interactive() draw_if_interactive()
finally: finally:
ax.hold(washold) ax.hold(washold)
sci(ret) sci(ret[0])
return ret return ret


# This function was autogenerated by boilerplate.py. Do not edit as # This function was autogenerated by boilerplate.py. Do not edit as
Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/streamplot.py
Expand Up @@ -108,6 +108,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
cmap = cm.get_cmap(cmap) cmap = cm.get_cmap(cmap)


streamlines = [] streamlines = []
arrows = []
for t in trajectories: for t in trajectories:
tgx = np.array(t[0]) tgx = np.array(t[0])
tgy = np.array(t[1]) tgy = np.array(t[1])
Expand Down Expand Up @@ -139,6 +140,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
transform=transform, transform=transform,
**arrow_kw) **arrow_kw)
axes.add_patch(p) axes.add_patch(p)
arrows.append(p)


lc = mcollections.LineCollection(streamlines, lc = mcollections.LineCollection(streamlines,
transform=transform, transform=transform,
Expand All @@ -151,7 +153,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,


axes.update_datalim(((x.min(), y.min()), (x.max(), y.max()))) axes.update_datalim(((x.min(), y.min()), (x.max(), y.max())))
axes.autoscale_view(tight=True) axes.autoscale_view(tight=True)
return lc
arrow_collection = matplotlib.collections.PatchCollection(arrows)
return lc, arrow_collection




# Coordinate definitions # Coordinate definitions
Expand Down

0 comments on commit 391c24a

Please sign in to comment.