Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25ba160

Browse files
committed
streamcontainer
1 parent f975291 commit 25ba160

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

lib/matplotlib/streamplot.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import matplotlib as mpl
99
from matplotlib import _api, cm, patches
10+
from matplotlib.container import Container
1011
import matplotlib.colors as mcolors
1112
import matplotlib.collections as mcollections
1213
import matplotlib.lines as mlines
@@ -76,17 +77,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
7677
7778
Returns
7879
-------
79-
StreamplotSet
80-
Container object with attributes
81-
82-
- ``lines``: `.LineCollection` of streamlines
83-
84-
- ``arrows``: `.PatchCollection` containing `.FancyArrowPatch`
85-
objects representing the arrows half-way along stream lines.
86-
87-
This container will probably change in the future to allow changes
88-
to the colormap, alpha, etc. for both lines and arrows, but these
89-
changes should be backward compatible.
80+
`~.StreamplotContainer`
9081
"""
9182
grid = Grid(x, y)
9283
mask = StreamMask(density)
@@ -237,20 +228,50 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
237228
axes.add_patch(p)
238229

239230
axes.autoscale_view()
240-
stream_container = StreamplotSet(lc, ac)
231+
stream_container = StreamplotContainer((lc, ac))
241232
return stream_container
242233

243234

235+
@_api.deprecated("major.minor", alternative="streamplot.StreamplotContainer")
244236
class StreamplotSet:
245-
246237
def __init__(self, lines, arrows):
247238
self.lines = lines
248239
self.arrows = arrows
249240

250241

242+
class StreamplotContainer(Container):
243+
"""
244+
`~.Container` object for artists created in an `~.Axes.streamplot` plot.
245+
246+
It can be treated like a namedtuple with fields ``(lines, arrows)``
247+
248+
.. versionadded major.minor ::
249+
250+
Attributes
251+
----------
252+
lines_arrows : tuple
253+
Tuple of (lines, arrows)
254+
``lines``: `.LineCollection` of the streamlines.
255+
``arrows``: `.PatchCollection` of the `.FancyArrowPatch` arrows
256+
half-way along each streamlines.
257+
258+
.. note::
259+
This container will probably change in the future to allow changes
260+
to the colormap, alpha, etc. for both lines and arrows, but these
261+
changes should be backward compatible.
262+
"""
263+
264+
def __init__(self, lines_arrows, **kwargs):
265+
lines, arrows = lines_arrows
266+
self.lines = lines
267+
self.arrows = arrows
268+
super().__init__(lines_arrows, **kwargs)
269+
270+
251271
# Coordinate definitions
252272
# ========================
253273

274+
254275
class DomainMap:
255276
"""
256277
Map representing different coordinate systems.

0 commit comments

Comments
 (0)