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
Inconsistent error when plotting with FuncAnimation vs plt.plot #19667
Comments
|
Oh, that makes more sense. Although I'm not sure I understand why these checks are done at the high level of Something like: if len(x) != len(y):
raise ValueError(f"x and y must have same dimension, but "
f"have shapes {len(x)} and {len(y)}") on line 652 of the following matplotlib/lib/matplotlib/lines.py Lines 640 to 654 in d69b42b
would surely help, but then this issue still persists if one uses Any ideas? Are there any other cases I'm missing? |
I'm pretty sure that x or y can be 2-D.... So we may need to trace down the logic in |
Alright, sure. We can do something like this then: if x.shape[0] != y.shape[0]:
raise ValueError(f"x and y must have same first dimension, but "
f"have shapes {x.shape} and {y.shape}")
if x.ndim > 2 or y.ndim > 2:
raise ValueError(f"x and y can be no greater than 2D, but have "
f"shapes {x.shape} and {y.shape}") Still, the problem with |
Bug report
Bug summary
The error thrown when there's a data mismatch when animating is not as expected, it doesn't get caught by matplotlib and instead numpy throws one. I was wondering if it would be possible to improve this error message and make it more informative. I wouldn't mind contributing to this small "quality of life" improvement, I'm just not sure where to start or if this is in fact an issue.
Code for reproduction
This error can be reproduced with the following code:
Actual outcome
When plotting data with different dimensions while animating we get the following error that is thrown by numpy:
Expected outcome
If we try plotting data with inconsistent dimensions (i.e:
plt.plot([1,2,3], [1, 2])
) we get the following error:I would expect the above code to produce a similar error.
Matplotlib version
The text was updated successfully, but these errors were encountered: