-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Milestone
Description
Bug summary
The type stub for ErrorbarContainer
in lib/matplotlib/container.pyi
is incorrect.
It is also inconsistent with the online documentation.
Code for reproduction
from matplotlib import pyplot as plt
fig = plt.figure()
axis = fig.add_subplot(111)
container = axis.errorbar([0, 1, 2], [-0.5, 0.2, 0.3], yerr=[0.01, 0.02, 0.01])
print(container.lines)
for idx, elem in enumerate(container.lines):
print(f"Element {idx}: {elem} | Type = {type(elem)}")
plt.show()
plt.close()
Actual outcome
Expected outcome
Assuming the type stub is correct:
- The first element should be a
Line2D
which is correct - The second element should be a
Line2D
which is incorrect as it is actually an empty tuple - The third element should be a
LineCollection
which is incorrect as it is a tuple containing a singleLineCollection
.
Additional information
I'm not sure if the type stub was always incorrect or it became incorrect over time however it should be fixed as it causes spurious type checker errors.
Obviously we would need to fix the type stub annotation however I am unsure about the true types as it seems that the return types are dynamic dependent on the input arguments to plt.errorbar.
Operating system
Debian
Matplotlib Version
3.8.4
Matplotlib Backend
QtAgg
Python version
3.12.4
Jupyter version
Not applicable
Installation
conda
Metadata
Metadata
Assignees
Labels
No labels