Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ca72da

Browse files
committed
Address JDH's PR comments
* Surround parameter names with asterisks (e.g. *param*) * Import `patches` instead of `mpp` * Use `cbook.is_numlike` instead of `isinstance`. * Fix outdated docstring.
1 parent b77effe commit 6ca72da

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/matplotlib/streamplot.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"""
55
import numpy as np
66
import matplotlib
7-
import matplotlib.patches as mpp
7+
import matplotlib.patches as patches
8+
import matplotlib.cbook as cbook
89

910

1011
__all__ = ['streamplot']
@@ -16,35 +17,34 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
1617
1718
Parameters
1819
----------
19-
x, y : 1d arrays
20+
*x*, *y* : 1d arrays
2021
an *evenly spaced* grid.
21-
u, v : 2d arrays
22+
*u*, *v* : 2d arrays
2223
x and y-velocities. Number of rows should match length of y, and
2324
the number of columns should match x.
24-
density : float or 2-tuple
25+
*density* : float or 2-tuple
2526
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.
2728
Each cell in the grid can have, at most, one traversing streamline.
2829
For different densities in each direction, use [density_x, density_y].
29-
linewidth : numeric or 2d array
30+
*linewidth* : numeric or 2d array
3031
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
3233
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
3636
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
3939
Factor scale arrow size.
40-
arrowstyle : str
40+
*arrowstyle* : str
4141
Arrow style specification. See `matplotlib.patches.FancyArrowPatch`.
42-
minlength : float
42+
*minlength* : float
4343
Minimum length of streamline in axes coordinates.
4444
4545
Returns
4646
-------
47-
streamlines : `matplotlib.collections.LineCollection`
47+
*streamlines* : `matplotlib.collections.LineCollection`
4848
Line collection with all streamlines as a series of line segments.
4949
Currently, there is no way to differentiate between line segments
5050
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,
130130
line_colors.extend(color_values)
131131
arrow_kw['color'] = cmap(norm(color_values[n]))
132132

133-
p = mpp.FancyArrowPatch(arrow_tail, arrow_head, **arrow_kw)
133+
p = patches.FancyArrowPatch(arrow_tail, arrow_head, **arrow_kw)
134134
axes.add_patch(p)
135135

136136
lc = matplotlib.collections.LineCollection(streamlines, **line_kw)
@@ -259,7 +259,7 @@ class StreamMask(object):
259259
"""
260260

261261
def __init__(self, density):
262-
if isinstance(density, (float, int)):
262+
if cbook.is_numlike(density):
263263
assert density > 0
264264
self.nx = self.ny = int(30 * density)
265265
else:

0 commit comments

Comments
 (0)