Skip to content

Commit aaeb4ea

Browse files
committed
Add streamplot with broken_streamlines=False test
Includes some style changes as requested by the matplotlib devs.
1 parent 5495fd2 commit aaeb4ea

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

lib/matplotlib/pyplot.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2909,14 +2909,16 @@ def streamplot(
29092909
x, y, u, v, density=1, linewidth=None, color=None, cmap=None,
29102910
norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1,
29112911
transform=None, zorder=None, start_points=None, maxlength=4.0,
2912-
integration_direction='both', broken_streamlines=True, *, data=None):
2912+
integration_direction='both', broken_streamlines=True, *,
2913+
data=None):
29132914
__ret = gca().streamplot(
29142915
x, y, u, v, density=density, linewidth=linewidth, color=color,
29152916
cmap=cmap, norm=norm, arrowsize=arrowsize,
29162917
arrowstyle=arrowstyle, minlength=minlength,
29172918
transform=transform, zorder=zorder, start_points=start_points,
29182919
maxlength=maxlength,
2919-
integration_direction=integration_direction, broken_streamlines=broken_streamlines,
2920+
integration_direction=integration_direction,
2921+
broken_streamlines=broken_streamlines,
29202922
**({"data": data} if data is not None else {}))
29212923
sci(__ret.lines)
29222924
return __ret

lib/matplotlib/streamplot.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
7070
Integrate the streamline in forward, backward or both directions.
7171
data : indexable object, optional
7272
DATA_PARAMETER_PLACEHOLDER
73-
broken_streamlines : If False, forces streamlines to continue until they
73+
broken_streamlines : boolean, default: True
74+
If False, forces streamlines to continue until they
7475
leave the plot domain. If True, they may be terminated if they
75-
come too close to another streamline. Default is True.
76+
come too close to another streamline.
7677
7778
Returns
7879
-------
@@ -482,13 +483,15 @@ def integrate(x0, y0, broken_streamlines=True):
482483
except InvalidIndexError:
483484
return None
484485
if integration_direction in ['both', 'backward']:
485-
s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength, broken_streamlines)
486+
s, xyt = _integrate_rk12(x0, y0, dmap, backward_time, maxlength,
487+
broken_streamlines)
486488
stotal += s
487489
xy_traj += xyt[::-1]
488490

489491
if integration_direction in ['both', 'forward']:
490492
dmap.reset_start_point(x0, y0)
491-
s, xyt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength, broken_streamlines)
493+
s, xyt = _integrate_rk12(x0, y0, dmap, forward_time, maxlength,
494+
broken_streamlines)
492495
stotal += s
493496
xy_traj += xyt[1:]
494497

lib/matplotlib/tests/test_streamplot.py

+12
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ def test_maxlength():
7777
ax.set(xlim=(None, 3.2555988021882305), ylim=(None, 3.078326760195413))
7878

7979

80+
@image_comparison(['streamplot_maxlength_no_broken.png'],
81+
remove_text=True, style='mpl20', tol=0.302)
82+
def test_maxlength_no_broken():
83+
x, y, U, V = swirl_velocity_field()
84+
ax = plt.figure().subplots()
85+
ax.streamplot(x, y, U, V, maxlength=10., start_points=[[0., 1.5]],
86+
linewidth=2, density=2, broken_streamlines=False)
87+
assert ax.get_xlim()[-1] == ax.get_ylim()[-1] == 3
88+
# Compatibility for old test image
89+
ax.set(xlim=(None, 3.2555988021882305), ylim=(None, 3.078326760195413))
90+
91+
8092
@image_comparison(['streamplot_direction.png'],
8193
remove_text=True, style='mpl20', tol=0.073)
8294
def test_direction():

0 commit comments

Comments
 (0)