8000 Fix argument checking in Axes3D.quiver · matplotlib/matplotlib@8f0792c · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f0792c

Browse files
committed
Fix argument checking in Axes3D.quiver
1 parent ba7f3f0 commit 8f0792c

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
15611561
The lightsource to use when *shade* is True.
15621562
15631563
**kwargs
1564-
Other arguments are forwarded to `.Poly3DCollection`.
1564+
Other keyword arguments are forwarded to `.Poly3DCollection`.
15651565
"""
15661566

15671567
had_data = self.has_data()
@@ -1724,7 +1724,7 @@ def plot_wireframe(self, X, Y, Z, **kwargs):
17241724
of the new default of ``rcount = ccount = 50``.
17251725
17261726
**kwargs
1727-
Other arguments are forwarded to `.Line3DCollection`.
1727+
Other keyword arguments are forwarded to `.Line3DCollection`.
17281728
"""
17291729

17301730
had_data = self.has_data()
@@ -1851,7 +1851,7 @@ def plot_trisurf(self, *args, color=None, norm=None, vmin=None, vmax=None,
18511851
lightsource : `~matplotlib.colors.LightSource`
18521852
The lightsource to use when *shade* is True.
18531853
**kwargs
1854-
All other arguments are passed on to
1854+
All other keyword arguments are passed on to
18551855
:class:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
18561856
18571857
Examples
@@ -2252,7 +2252,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
22522252
data : indexable object, optional
22532253
DATA_PARAMETER_PLACEHOLDER
22542254
**kwargs
2255-
All other arguments are passed on to `~.axes.Axes.scatter`.
2255+
All other keyword arguments are passed on to `~.axes.Axes.scatter`.
22562256
22572257
Returns
22582258
-------
@@ -2304,7 +2304,8 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
23042304
data : indexable object, optional
23052305
DATA_PARAMETER_PLACEHOLDER
23062306
**kwargs
2307-
Other arguments are forwarded to `matplotlib.axes.Axes.bar`.
2307+
Other keyword arguments are forwarded to
2308+
`matplotlib.axes.Axes.bar`.
23082309
23092310
Returns
23102311
-------
@@ -2508,19 +2509,16 @@ def set_title(self, label, fontdict=None, loc='center', **kwargs):
25082509
return ret
25092510

25102511
@_preprocess_data()
2511-
def quiver(self, *args,
2512+
def quiver(self, X, Y, Z, U, V, W, *,
25122513
length=1, arrow_length_ratio=.3, pivot='tail', normalize=False,
25132514
**kwargs):
25142515
"""
2515-
ax.quiver(X, Y, Z, U, V, W, /, length=1, arrow_length_ratio=.3, \
2516-
pivot='tail', normalize=False, **kwargs)
2517-
25182516
Plot a 3D field of arrows.
25192517
2520-
The arguments could be array-like or scalars, so long as they
2521-
they can be broadcast together. The arguments can also be
2522-
masked arrays. If an element in any of argument is masked, then
2523-
that corresponding quiver element will not be plotted.
2518+
The arguments can be array-like or scalars, so long as they can be
2519+
broadcast together. The arguments can also be masked arrays. If an
2520+
element in any of argument is masked, then that corresponding quiver
2521+
element will not be plotted.
25242522
25252523
Parameters
25262524
----------
@@ -2550,7 +2548,7 @@ def quiver(self, *args,
25502548
25512549
**kwargs
25522550
Any additional keyword arguments are delegated to
2553-
:class:`~matplotlib.collections.LineCollection`
2551+
:class:`.Line3DCollection`
25542552
"""
25552553

25562554
def calc_arrows(UVW, angle=15):
@@ -2581,22 +2579,15 @@ def calc_arrows(UVW, angle=15):
25812579

25822580
had_data = self.has_data()
25832581

2584-
# handle args
2585-
argi = 6
2586-
if len(args) < argi:
2587-
raise ValueError('Wrong number of arguments. Expected %d got %d' %
2588-
(argi, len(args)))
2589-
2590-
# first 6 arguments are X, Y, Z, U, V, W
2591-
input_args = args[:argi]
2582+
input_args = [X, Y, Z, U, V, W]
25922583

25932584
# extract the masks, if any
25942585
masks = [k.mask for k in input_args
25952586
if isinstance(k, np.ma.MaskedArray)]
25962587
# broadcast to match the shape
25972588
bcast = np.broadcast_arrays(*input_args, *masks)
2598-
input_args = bcast[:argi]
2599-
masks = bcast[argi:]
2589+
input_args = bcast[:6]
2590+
masks = bcast[6:]
26002591
if masks:
26012592
# combine the masks into one
26022593
mask = functools.reduce(np.logical_or, masks)
@@ -2608,7 +2599,7 @@ def calc_arrows(UVW, angle=15):
26082599

26092600
if any(len(v) == 0 for v in input_args):
26102601
# No quivers, so just make an empty collection and return early
2611-
linec = art3d.Line3DCollection([], *args[argi:], **kwargs)
2602+
linec = art3d.Line3DCollection([], **kwargs)
26122603
self.add_collection(linec)
26132604
return linec
26142605

@@ -2622,7 +2613,7 @@ def calc_arrows(UVW, angle=15):
26222613
shaft_dt -= length / 2
26232614

26242615
XYZ = np.column_stack(input_args[:3])
2625-
UVW = np.column_stack(input_args[3:argi]).astype(float)
2616+
UVW = np.column_stack(input_args[3:]).astype(float)
26262617

26272618
# Normalize rows of UVW
26282619
norm = np.linalg.norm(UVW, axis=1)
@@ -2651,7 +2642,7 @@ def calc_arrows(UVW, angle=15):
26512642
else:
26522643
lines = []
26532644

2654-
linec = art3d.Line3DCollection(lines, *args[argi:], **kwargs)
2645+
linec = art3d.Line3DCollection(lines, **kwargs)
26552646
self.add_collection(linec)
26562647

26572648
self.auto_scale_xyz(XYZ[:, 0], XYZ[:, 1], XYZ[:, 2], had_data)

0 commit comments

Comments
 (0)
0