8000 Rename n_arrows to num_arrows · matplotlib/matplotlib@690d255 · GitHub
[go: up one dir, main page]

Skip to content

Commit 690d255

Browse files
committed
Rename n_arrows to num_arrows
1 parent b2843d5 commit 690d255

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

doc/users/next_whats_new/streamplot_multiple_arrows.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Multiple arrows on a streamline
22
-------------------------------
33

4-
A new ``n_arrows`` argument has been added to `~matplotlib.axes.Axes.streamplot` that
4+
A new ``num_arrows`` argument has been added to `~matplotlib.axes.Axes.streamplot` that
55
allows more than one arrow to be added to each streamline:
66

77
.. plot::
@@ -17,6 +17,6 @@ allows more than one arrow to be added to each streamline:
1717
V = 1 + X - Y**2
1818

1919
fig, ax = plt.subplots()
20-
ax.streamplot(X, Y, U, V, n_arrows=3)
20+
ax.streamplot(X, Y, U, V, num_arrows=3)
2121

2222
plt.show()

galleries/examples/images_contours_and_fields/plot_streamplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
axs[3].set(xlim=(-w, w), ylim=(-w, w))
5454

5555
# Adding more than one arrow to each streamline
56-
axs[4].streamplot(X, Y, U, V, n_arrows=3)
56+
axs[4].streamplot(X, Y, U, V, num_arrows=3)
5757
axs[4].set_title('Multiple arrows')
5858

5959
axs[5].axis("off")

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4125,7 +4125,7 @@ def streamplot(
41254125
integration_direction="both",
41264126
broken_streamlines=True,
41274127
*,
4128-
n_arrows=1,
4128+
num_arrows=1,
41294129
data=None,
41304130
):
41314131
__ret = gca().streamplot(
@@ -4147,7 +4147,7 @@ def streamplot(
41474147
maxlength=maxlength,
41484148
integration_direction=integration_direction,
41494149
broken_streamlines=broken_streamlines,
4150-
n_arrows=n_arrows,
4150+
num_arrows=num_arrows,
41514151
**({"data": data} if data is not None else {}),
41524152
)
41534153
sci(__ret.lines)

lib/matplotlib/streamplot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
1919
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
2020
minlength=0.1, transform=None, zorder=None, start_points=None,
2121
maxlength=4.0, integration_direction='both',
22-
broken_streamlines=True, *, n_arrows=1):
22+
broken_streamlines=True, *, num_arrows=1):
2323
"""
2424
Draw streamlines of a vector flow.
2525
@@ -73,7 +73,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
7373
If False, forces streamlines to continue until they
7474
leave the plot domain. If True, they may be terminated if they
7575
come too close to another streamline.
76-
n_arrows : int
76+
num_arrows : int
7777
Number of arrows per streamline. The arrows are spaced equally along the steps
7878
each streamline takes. Note that this can be different to being spaced equally
7979
along the distance of the streamline.
@@ -97,8 +97,8 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
9797
mask = StreamMask(density)
9898
dmap = DomainMap(grid, mask)
9999

100-
if n_arrows < 0:
101-
raise ValueError(f"The value of n_arrows must be >= 0, got {n_arrows=}")
100+
if num_arrows < 0:
101+
raise ValueError(f"The value of num_arrows must be >= 0, got {num_arrows=}")
102102

103103
if zorder is None:
104104
zorder = mlines.Line2D.zorder
@@ -221,9 +221,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
221221
line_colors.append(color_values)
222222

223223
# Add arrows along each trajectory.
224-
for x in range(1, n_arrows+1):
224+
for x in range(1, num_arrows+1):
225225
# Get index of distance along streamline to place arrow
226-
idx = np.searchsorted(s, s[-1] * (x/(n_arrows+1)))
226+
idx = np.searchsorted(s, s[-1] * (x/(num_arrows+1)))
227227
arrow_tail = (tx[idx], ty[idx])
228228
arrow_head = (np.mean(tx[idx:idx + 2]), np.mean(ty[idx:idx + 2]))
229229

lib/matplotlib/streamplot.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def streamplot(
2929
integration_direction: Literal["forward", "backward", "both"] = ...,
3030
broken_streamlines: bool = ...,
3131
*,
32-
n_arrows: int = ...,
32+
num_arrows: int = ...,
3333
) -> StreamplotSet: ...
3434

3535
class StreamplotSet:

lib/matplotlib/tests/test_streamplot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def swirl_velocity_field():
2626
@image_comparison(['streamplot_startpoints'], remove_text=True, style='mpl20',
2727
extensions=['png'])
2828
def test_startpoints():
29-
# Test varying startpoints. Also tests a non-default n_arrows argument.
29+
# Test varying startpoints. Also tests a non-default num_arrows argument.
3030
X, Y, U, V = velocity_field()
3131
start_x, start_y = np.meshgrid(np.linspace(X.min(), X.max(), 5),
3232
np.linspace(Y.min(), Y.max(), 5))
3333
start_points = np.column_stack([start_x.ravel(), start_y.ravel()])
34-
plt.streamplot(X, Y, U, V, start_points=start_points, n_arrows=4)
34+
plt.streamplot(X, Y, U, V, start_points=start_points, num_arrows=4)
3535
plt.plot(start_x, start_y, 'ok')
3636

3737

0 commit comments

Comments
 (0)
0