10
10
__all__ = ['streamplot' ]
11
11
12
12
13
- def streamplot (axes , x , y , u , v , density = 1 , linewidth = 1 , color = 'k' , cmap = None ,
14
- arrowsize = 1 , arrowstyle = '-|>' , minlength = 0.1 ):
13
+ def streamplot (axes , x , y , u , v , density = 1 , linewidth = None , color = None ,
14
+ cmap = None , arrowsize = 1 , arrowstyle = '-|>' , minlength = 0.1 ):
15
15
"""Draws streamlines of a vector flow.
16
16
17
17
Parameters
@@ -56,13 +56,26 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
56
56
57
57
if color is None :
58
58
color = matplotlib .rcParams ['lines.color' ]
59
- elif isinstance (color , np .ndarray ):
60
- assert color .shape == grid .shape
61
59
62
60
if linewidth is None :
63
61
linewidth = matplotlib .rcParams ['lines.linewidth' ]
64
- elif isinstance (linewidth , np .ndarray ):
62
+
63
+ line_kw = {}
64
+ arrow_kw = dict (arrowstyle = arrowstyle , mutation_scale = 10 * arrowsize )
65
+
66
+ if isinstance (color , np .ndarray ):
67
+ assert color .shape == grid .shape
68
+ line_colors = []
69
+ else :
70
+ line_kw ['color' ] = color
71
+ arrow_kw ['color' ] = color
72
+
73
+ if isinstance (linewidth , np .ndarray ):
65
74
assert linewidth .shape == grid .shape
75
+ line_kw ['linewidth' ] = []
76
+ else :
77
+ line_kw ['linewidth' ] = linewidth
78
+ arrow_kw ['linewidth' ] = linewidth
66
79
67
80
## Sanity checks.
68
81
assert u .shape == grid .shape
@@ -89,20 +102,6 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=1, color='k', cmap=None,
89
102
if cmap == None : cmap = matplotlib .cm .get_cmap (
90
103
matplotlib .rcParams ['image.cmap' ])
91
104
92
- line_kw = {}
93
- arrow_kw = dict (arrowstyle = arrowstyle , mutation_scale = 10 * arrowsize )
94
-
95
- if isinstance (linewidth , np .ndarray ):
96
- line_kw ['linewidth' ] = []
97
- else :
98
- line_kw ['linewidth' ] = linewidth
99
- arrow_kw ['linewidth' ] = linewidth
100
-
101
- if isinstance (color , np .ndarray ):
102
- line_colors = []
103
- else :
104
- line_kw ['color' ] = color
105
- arrow_kw ['color' ] = color
106
105
107
106
streamlines = []
108
107
for t in trajectories :
0 commit comments