4
4
"""
5
5
import numpy as np
6
6
import matplotlib
7
- import matplotlib .patches as mpp
7
+ import matplotlib .patches as patches
8
+ import matplotlib .cbook as cbook
8
9
9
10
10
11
__all__ = ['streamplot' ]
@@ -16,35 +17,34 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
16
17
17
18
Parameters
18
19
----------
19
- x, y : 1d arrays
20
+ *x*, *y* : 1d arrays
20
21
an *evenly spaced* grid.
21
- u, v : 2d arrays
22
+ *u*, *v* : 2d arrays
22
23
x and y-velocities. Number of rows should match length of y, and
23
24
the number of columns should match x.
24
- density : float or 2-tuple
25
+ * density* : float or 2-tuple
25
26
Controls the closeness of streamlines. When `density = 1`, the domain
26
- is divided into a 25x25 grid---` density` linearly scales this grid.
27
+ is divided into a 25x25 grid---* density* linearly scales this grid.
27
28
Each cell in the grid can have, at most, one traversing streamline.
28
29
For different densities in each direction, use [density_x, density_y].
29
- linewidth : numeric or 2d array
30
+ * linewidth* : numeric or 2d array
30
31
vary linewidth when given a 2d array with the same shape as velocities.
31
- color : matplotlib color code, or 2d array
32
+ * color* : matplotlib color code, or 2d array
32
33
Streamline color. When given an array with the same shape as
33
- velocities, values are converted to color using cmap, norm, vmin and
34
- vmax args.
35
- cmap : Colormap
34
+ velocities, *color* values are converted to colors using *cmap*.
35
+ *cmap* : Colormap
36
36
Colormap used to plot streamlines and arrows. Only necessary when using
37
- an array input for ` color` .
38
- arrowsize : float
37
+ an array input for * color* .
38
+ * arrowsize* : float
39
39
Factor scale arrow size.
40
- arrowstyle : str
40
+ * arrowstyle* : str
41
41
Arrow style specification. See `matplotlib.patches.FancyArrowPatch`.
42
- minlength : float
42
+ * minlength* : float
43
43
Minimum length of streamline in axes coordinates.
44
44
45
45
Returns
46
46
-------
47
- streamlines : `matplotlib.collections.LineCollection`
47
+ * streamlines* : `matplotlib.collections.LineCollection`
48
48
Line collection with all streamlines as a series of line segments.
49
49
Currently, there is no way to differentiate between line segments
50
50
on different streamlines (other than manually checking that segments
@@ -130,7 +130,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
130
130
line_colors .extend (color_values )
131
131
arrow_kw ['color' ] = cmap (norm (color_values [n ]))
132
132
133
- p = mpp .FancyArrowPatch (arrow_tail , arrow_head , ** arrow_kw )
133
+ p = patches .FancyArrowPatch (arrow_tail , arrow_head , ** arrow_kw )
134
134
axes .add_patch (p )
135
135
136
136
lc = matplotlib .collections .LineCollection (streamlines , ** line_kw )
@@ -259,7 +259,7 @@ class StreamMask(object):
259
259
"""
260
260
261
261
def __init__ (self , density ):
262
- if isinstance (density , ( float , int ) ):
262
+ if cbook . is_numlike (density ):
263
263
assert density > 0
264
264
self .nx = self .ny = int (30 * density )
265
265
else :
0 commit comments