Skip to content

Return arrow collection as 2nd argument of streamplot. #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 2, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change return value of streamplot.
- Return object that derives from `object` since deriving from `Container` was not beneficial.
- This return value is a stopgap; the final return value should allow users to set the colormap, alpha, etc. for both lines and arrows.
  • Loading branch information
tonysyu committed Sep 2, 2012
commit 9875323ed79767751f05a109e44c5da7556e6ce2
13 changes: 4 additions & 9 deletions lib/matplotlib/streamplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import matplotlib.colors as mcolors
import matplotlib.collections as mcollections
import matplotlib.patches as patches
import matplotlib.container as container


__all__ = ['streamplot']
Expand Down Expand Up @@ -50,7 +49,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,

Returns
-------
*stream_container* : StreamplotContainer
*stream_container* : StreamplotSet
Container object with attributes
lines : `matplotlib.collections.LineCollection` of streamlines
arrows : collection of `matplotlib.patches.FancyArrowPatch` objects
Expand Down Expand Up @@ -159,19 +158,15 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
axes.autoscale_view(tight=True)

ac = matplotlib.collections.PatchCollection(arrows)
stream_container = StreamplotContainer(lc, arrows=ac)
stream_container = StreamplotSet(lc, ac)
return stream_container


class StreamplotContainer(container.Container):
class StreamplotSet(object):

def __new__(cls, *kl, **kwargs):
return tuple.__new__(cls)

def __init__(self, lines, arrows=None, **kwargs):
def __init__(self, lines, arrows, **kwargs):
self.lines = lines
self.arrows = arrows
container.Container.__init__(self, lines, **kwargs)


# Coordinate definitions
Expand Down