Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
22 changes: 11 additions & 11 deletionslib/matplotlib/axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6601,17 +6601,17 @@ def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
minlength=0.1, transform=None):
if not self._hold: self.cla()
lines = mstream.streamplot(self, x, y, u, v,
density=density,
linewidth=linewidth,
color=color,
cmap=cmap,
norm=norm,
arrowsize=arrowsize,
arrowstyle=arrowstyle,
minlength=minlength,
transform=transform)
returnlines
stream_container = mstream.streamplot(self, x, y, u, v,
density=density,
linewidth=linewidth,
color=color,
cmap=cmap,
norm=norm,
arrowsize=arrowsize,
arrowstyle=arrowstyle,
minlength=minlength,
transform=transform)
returnstream_container
streamplot.__doc__ = mstream.streamplot.__doc__

@docstring.dedent_interpd
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3055,7 +3055,7 @@ def streamplot(x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
draw_if_interactive()
finally:
ax.hold(washold)
sci(ret)
sci(ret.lines)
return ret

# This function was autogenerated by boilerplate.py. Do not edit as
Expand Down
30 changes: 24 additions & 6 deletionslib/matplotlib/streamplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
import matplotlib.collections as mcollections
import matplotlib.patches as patches


__all__ = ['streamplot']


Expand DownExpand Up@@ -46,11 +47,16 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
*minlength* : float
Minimum length of streamline in axes coordinates.

Returns *streamlines* : :class:`~matplotlib.collections.LineCollection`
Line collection with all streamlines as a series of line segments.
Currently, there is no way to differentiate between line segments
on different streamlines (other than manually checking that segments
are connected).
Returns
-------
*stream_container* : StreamplotSet
Container object with attributes
lines : `matplotlib.collections.LineCollection` of streamlines
arrows : collection of `matplotlib.patches.FancyArrowPatch` objects
repesenting arrows half-way along stream lines.
This container will probably change in the future to allow changes to
the colormap, alpha, etc. for both lines and arrows, but these changes
should be backward compatible.
"""
grid = Grid(x, y)
mask = StreamMask(density)
Expand DownExpand Up@@ -108,6 +114,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
cmap = cm.get_cmap(cmap)

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

lc = mcollections.LineCollection(streamlines,
transform=transform,
Expand All@@ -151,7 +159,17 @@ 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.autoscale_view(tight=True)
return lc

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


class StreamplotSet(object):

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


# Coordinate definitions
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp