Closed
Description
Bug report
Bug summary
Bug: matplotlib.pyplot.quiver cannot accept X, Y, U, V and C as keyword arguments, such operation leads to an IndexError: pop from empty list
(if all of them are keyword arguments) or an AttributeError: Unknown property *
(if part of them are keyword arguments). This error arises because line 444 in quiver.py
, inside the constructor of Quiver class, only uses *args
but excludes **kw
for parsing of arguments X, Y, U, V and C, and thus nothing can be parsed from *args
in the function _parse_args
on line 385 if these arguments are given by keywords.
Code for reproduction
import matplotlib.pyplot as plt
x, y, u, v = 0, 0, .01, .02
plt.quiver(X=x, Y=y, U=u, V=v, units='xy', scale=1)
plt.show()
Actual outcome
Traceback (most recent call last):
File "untitled.py", line 5, in <module>
plt.quiver(X=x, Y=y, U=u, V=v, units='xy', scale=1)
File "/usr/local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 3425, in quiver
ret = ax.quiver(*args, **kw)
File "/usr/local/lib/python3.6/site-packages/matplotlib/__init__.py", line 1855, in inner
return func(ax, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 4872, in quiver
q = mquiver.Quiver(self, *args, **kw)
File "/usr/local/lib/python3.6/site-packages/matplotlib/quiver.py", line 444, in __init__
X, Y, U, V, C = _parse_args(*args)
File "/usr/local/lib/python3.6/site-packages/matplotlib/quiver.py", line 393, in _parse_args
V = np.atleast_1d(args.pop(-1))
IndexError: pop from empty list
And the error disappears if we write the code as plt.quiver(x, y, u, v, units='xy', scale=1)
.
Matplotlib version
- Operating system: Mac OS High Sierra
- Matplotlib version: 2.2.2 (installed from pip3)
- Matplotlib backend: MacOSX
- Python version: 3.6.5