|
7 | 7 |
|
8 | 8 | import matplotlib as mpl
|
9 | 9 | from matplotlib import _api, cm, patches
|
| 10 | +from matplotlib.container import Container |
10 | 11 | import matplotlib.colors as mcolors
|
11 | 12 | import matplotlib.collections as mcollections
|
12 | 13 | import matplotlib.lines as mlines
|
@@ -76,17 +77,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
|
76 | 77 |
|
77 | 78 | Returns
|
78 | 79 | -------
|
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` |
90 | 81 | """
|
91 | 82 | grid = Grid(x, y)
|
92 | 83 | mask = StreamMask(density)
|
@@ -237,20 +228,50 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
|
237 | 228 | axes.add_patch(p)
|
238 | 229 |
|
239 | 230 | axes.autoscale_view()
|
240 |
| - stream_container = StreamplotSet(lc, ac) |
| 231 | + stream_container = StreamplotContainer((lc, ac)) |
241 | 232 | return stream_container
|
242 | 233 |
|
243 | 234 |
|
| 235 | +@_api.deprecated("major.minor", alternative="streamplot.StreamplotContainer") |
244 | 236 | class StreamplotSet:
|
245 |
| - |
246 | 237 | def __init__(self, lines, arrows):
|
247 | 238 | self.lines = lines
|
248 | 239 | self.arrows = arrows
|
249 | 240 |
|
250 | 241 |
|
| 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 | + |
251 | 271 | # Coordinate definitions
|
252 | 272 | # ========================
|
253 | 273 |
|
| 274 | + |
254 | 275 | class DomainMap:
|
255 | 276 | """
|
256 | 277 | Map representing different coordinate systems.
|
|
0 commit comments