-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Enforce that Line data modifications are sequences #28927
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
There is no easy solution. The created Line2D is a generic independent object, which doesn't know about the "single y-value" property of a horizontal line. Options are:
My preference is (4) > (2) > (1) > (3) Edit: There is one more way that's in a sense even hackier than (3) but may limit unintended fallout. If a scalar is passed: Check if all existing values are the same, and if so, replace the values. 🤯 |
I came across this because I'd had code that was working for a long time (axvline + axhline), and suddenly set_ydata/set_xdata failed, without a visible deprecation warning. I fixed the code in my project, and because we make regular releases it'll limit the fallout. Perhaps a documentation fix will be enough? |
Bug summary
It used to be possible to use
Line2D.set_ydata
with a single scalar. From a quick search I think this behaviour was changed in #22329, and I guess it makes sense for a lot of cases. However, I don't think mandating a sequence really makes sense whenLine2D
was created byax.axhline
, orax.axvline
, because those two methods use scalars themselves, not sequences.Code for reproduction
Actual outcome
Expected outcome
A plot with horizontal/vertical line
Additional information
No response
Operating system
No response
Matplotlib Version
3.9.2
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: