|
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,9 @@ 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 |
| 80 | + `~.StreamplotContainer` |
81 | 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. |
| 82 | + .. versionchanged major.minor:: |
90 | 83 | """
|
91 | 84 | grid = Grid(x, y)
|
92 | 85 | mask = StreamMask(density)
|
@@ -237,20 +230,57 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
|
237 | 230 | axes.add_patch(p)
|
238 | 231 |
|
239 | 232 | axes.autoscale_view()
|
240 |
| - stream_container = StreamplotSet(lc, ac) |
| 233 | + stream_container = StreamplotContainer((lc, ac)) |
241 | 234 | return stream_container
|
242 | 235 |
|
243 | 236 |
|
| 237 | +@_api.deprecated("major.minor", alternative="streamplot.StreamplotContainer") |
244 | 238 | class StreamplotSet:
|
245 |
| - |
246 | 239 | def __init__(self, lines, arrows):
|
247 | 240 | self.lines = lines
|
248 | 241 | self.arrows = arrows
|
249 | 242 |
|
250 | 243 |
|
| 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 | + |
251 | 280 | # Coordinate definitions
|
252 | 281 | # ========================
|
253 | 282 |
|
| 283 | + |
254 | 284 | class DomainMap:
|
255 | 285 | """
|
256 | 286 | Map representing different coordinate systems.
|
|
0 commit comments