8000 Changed streamplot return type: StreamplotSet->StreamplotContainer · matplotlib/matplotlib@833d45a · GitHub
[go: up one dir, main page]

Skip to content

Commit 833d45a

Browse files
committed
Changed streamplot return type: StreamplotSet->StreamplotContainer
Deprecated StreamplotSet Added StreamplotContainer
1 parent f975291 commit 833d45a

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

lib/matplotlib/streamplot.py

Lines changed: 42 additions & 12 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,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
7677
7778
Returns
7879
-------
79-
StreamplotSet
80-
Container object with attributes
80+
`~.StreamplotContainer`
8181
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.
82+
.. versionchanged major.minor::
9083
"""
9184
grid = Grid(x, y)
9285
mask = StreamMask(density)
@@ -237,20 +230,57 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
237230
axes.add_patch(p)
238231

239232
axes.autoscale_view()
240-
stream_container = StreamplotSet(lc, ac)
233+
stream_container = StreamplotContainer((lc, ac))
241234
return stream_container
242235

243236

237+
@_api.deprecated("major.minor", alternative="streamplot.StreamplotContainer")
244238
class StreamplotSet:
245-
246239
def __init__(self, lines, arrows):
247240
self.lines = lines
248241
self.arrows = arrows
249242

250243

244+
class StreamplotContainer(Container):
245+
"""
246+
`~.Container` object for artists created in an `~.Axes.streamplot` plot.
247+
248+
It can be treated like a namedtuple with fields ``(lines, arrows)``
249+
250+
.. versionadded major.minor ::
251+
252+
Attributes
253+
----------
254+
lines: `~.LineCollection`
255+
` The collection of `.Line2d` segments that make up the streamlines
256+
arrows: `~.PatchCollection`
257+
The collection of `.FancyArrow` arrows half-way along each streamline
258+
259+
.. note::
260+
This container will probably change in the future to allow changes
261+
to the colormap, alpha, etc. for both lines and arrows, but these
262+
changes should be backward compatible.
263+
"""
264+
265+
def __init__(self, lines_arrows, **kwargs):
266+
"""
267+
Parameters
268+
----------
269+
lines_arrows : tuple
270+
Tuple of (lines, arrows)
271+
``lines``: `.LineCollection` of streamlines.
272+
``arrows``: `.PatchCollection` of `.FancyArrowPatch` arrows
273+
"""
274+
lines, arrows = lines_arrows
275+
self.lines = lines
276+
self.arrows = arrows
277+
super().__init__(lines_arrows, **kwargs)
278+
279+
251280
# Coordinate definitions
252281
# ========================
253282

283+
254284
class DomainMap:
255285
"""
256286
Map representing different coordinate systems.

0 commit comments

Comments
 (0)
0