-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Changing the array returned by get_data affects future calls to get_data but does not change the plot on canvas.draw. #29760
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
To start with a joke: There are 2 hard problems in computer science: naming things, cache invalidation, and off-by-one bugs. The issue is that, for performance reasons, we do some caching in If you I hope that made sense how we got here and why the current behavior is the way it is. Paths out:
I'm inclined to go with option 1 and better document how to force a re-cache of the Line. I am not sure it is a good idea to mutate data arrays is place and recache (calling [edited to fix a typo] |
|
Bug summary
I use get_ydata for simplicity. I call it twice, with orig=True and False, respectively, storing the returned arrays as yT and yF, which are then changed. The drawn position is the original one, seems to be a third entity, maybe cached.
Using set_ydata moves the marker, but does not touch the arrays yT and yF.
If not a bug, it is a usability issue: My application calls set_data conditionally after changing the arrays, and if not, the result of future calls to get_data didn't reflect the marker position, which took some time to debug.
Code for reproduction
Actual outcome
Given as comments in the code.
Expected outcome
Either
get_data
shall return a copy, which can be changed independently of the artist, or the canvas shall reflect changes to the artist's state.The documentation of the
orig
parameter is insufficient.Additional information
#24790 links a pull request mentioning caching.
Operating system
Windows 10
Matplotlib Version
3.10.0
Matplotlib Backend
tkagg
Python version
3.13.1
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: