-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Unable to pickle figure with aligned labels #25329
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
As you've noted, pickling is pretty fragile. Do you need to pickle? |
I have embedded matplotlib in PySide6 and use it for plotting and analyzing time based 2-D data. This tool is used by people with no prior experience of python/matplotlib. Everything is done through UI. There is no scripting required to generate figures. I was looking for a way to save the generated figures for future changes. So basically I want to pickle a figure object, compress it (size reduction+encryption) and then save it to disk. When reading the file back, I can decompress the file and then add figure object to canvas. I understand pickling is not recommended for saving figures due to security issues/matplotlib version mismatch etc issues. (as discussed in #15381). But there is no script used here to generate the figure. I got some hope when issue #22482 was fixed. Hence I decided to raise other issues that I faced when pickling. Thanks for all the help. specially @anntzer |
Confirming #25332 fixes this issue. |
yes, we committed to Figures being pickable a while ago and I do not think we should back out of that. The interactive stuff is on the edge and I think it is OK to say "you lose custom callback on un-pickle" because scope creep needs to be stopped, anything essentially static should work. |
If it is all in a UI, then the things the user can do are (very) limited, I suspect it would be possible to describe generating the figure as a series of steps that they did. Rather than using a pickle like this (you could argue that because you own both read/write it is ok-ish, but it still leaves an injection attach e.g. person B emails person A an "output" from your program which is malicious you are not actually getting around any of the security issues with pickle inherent with pickles) it would be better to write down the sequence of steps the user did and the replay those steps on load. |
Bug summary
Unable to pickle figure after calling
align_labels()
Code for reproduction
Actual outcome
Expected outcome
Pickling successful
Additional information
No response
Operating system
Windows
Matplotlib Version
3.7.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
The text was updated successfully, but these errors were encountered: