-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Matplotlib.pyplot.quiver does not accept X, Y, U, V and C as keyword arguments #11526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That does seem like a mistake, want to take a crack at fixing it @niwatori1217 ? |
Looking at this again I am tempted to say that we should just declare that these arguments are positional-only. The problem is that adding keyword support is only going to make a confusing API even more worse: for example, do we expect that in
I think there's some similarly, the builtin |
I agree that the mix is very confusing, but would allowing all kwarg or all arg make sense? |
Honestly I don't really see the point... Documenting xyuvc as positional only seems simpler than "positional only, or all keyword". |
Up to five positional arguments are not that nice, in particular since the meaning of the arguments depends on the number of arguments used.
However, adding more options does not simplify the present signature of I would in principle be fine with all-kwarg signatures:
That could in principle catch errors of using the wrong arguments or positions. Say, you want to use X, Y, U, V and you miss V, you would accidentially end up with U, V, C semantics. On the downside, I don't think that the all-kwarg variants add to readability. And internally this would add to the complexity of argument parsing. Note also, that other similar functions like Overall, I'm -0.5 on supporting all-kwarg as well here. |
fair enough. |
@niwatori1217 Thanks for the suggestion, however we are probably not going to implement this 😞 . Hopefully we will hear from you again! |
…ositional-only Closes matplotlib#28047 and the already closed matplotlib#11526. This introduces the positional-only marker `/` into the call signatures (`pcolorfast` already had it). While IIRC I originally opted against adding it for simplicity, the above issues show that this is not clear enough. It's helpful for experienced people and I believe it does not distract people who don't know what it is too much because it's here always at the end before **kwargs. Additionally, it does not hurt to spell it out in text as well.
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 anAttributeError: Unknown property *
(if part of them are keyword arguments). This error arises because line 444 inquiver.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
Actual outcome
And the error disappears if we write the code as
plt.quiver(x, y, u, v, units='xy', scale=1)
.Matplotlib version
The text was updated successfully, but these errors were encountered: