-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: Saving a figure with indicate_inset_zoom to pdf and then pickling it causes TypeError #27805
Comments
The culprit here appears to be these two lines in matplotlib/lib/matplotlib/patches.py Lines 4699 to 4700 in 897dd0a
Namely, that the ConnectionPatch object (which is used to draw the zoom lines in This combined with the fact that the PDF backend holds a reference to a BytesIO object (as well as I believe at least one other unpicklable generator object... didn't trace exactly where that came from, but was able to poke it to give me a different error) means that upon drawing with the PDF backend the ConnectionPatch becomes unpicklable. As far as I can tell, there is no reason to hold a reference here, it is never accessed. It has existed in this class since the beginning (August of 2009). There are a handful of other places we store a renderer to an instance attribute, as a roundup:
|
As far as I can tell, these are unused, and cause problems for pickling Closes matplotlib#27805
As far as I can tell, these are unused, and cause problems for pickling Closes matplotlib#27805
As far as I can tell, these are unused, and cause problems for pickling Closes matplotlib#27805
Bug summary
If a fig with an ax using the indicate_inset_zoom is saved to pdf and then pickled, one gets the following error:
Code for reproduction
Actual outcome
Expected outcome
The expected outcome would be no TypeError
Additional information
Saving to pickle before saving the figure is a workaround.
Operating system
Windows 10
Matplotlib Version
3.7.1 and 3.8.3
Matplotlib Backend
TkAgg
Python version
3.10.11
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: