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

Skip to content

Commit 54177a4

Browse files
committed
Merge pull request #729 from tonysyu/fix-streamplot
Fix error when multiple densities passed to streamplot.
2 parents 48590f3 + 4649b66 commit 54177a4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

examples/pylab_examples/streamplot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
plt.colorbar()
1111

1212
f, (ax1, ax2) = plt.subplots(ncols=2)
13-
ax1.streamplot(X, Y, U, V)
13+
ax1.streamplot(X, Y, U, V, density=[0.5, 1])
1414

1515
lw = 5*speed/speed.max()
1616
ax2.streamplot(X, Y, U, V, density=0.6, color='k', linewidth=lw)

lib/matplotlib/streamplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ class StreamMask(object):
259259
"""
260260

261261
def __init__(self, density):
262-
if cbook.is_numlike(density):
262+
if np.isscalar(density):
263263
assert density > 0
264264
self.nx = self.ny = int(30 * density)
265265
else:
266-
assert len(density) > 0
266+
assert len(density) == 2
267267
self.nx = int(25 * density[0])
268268
self.ny = int(25 * density[1])
269269
self._mask = np.zeros((self.ny, self.nx))

0 commit comments

Comments
 (0)