Open raamana opened 1 year ago
likely related to this 2015 comment from @tacaswell : Apparently the remove is not doing enough clean up
: https://github.com/matplotlib/matplotlib/issues/5663/#issuecomment-164228174
At the moment, I think you can workaround this by calling radio.disconnect_events()
before removing the Axes
.
This is likely related to #25274, although this is likely different enough to warrant its own issue. The legend appears to be unstable right now.
I do not think this is related to #25274 as in that case the Container
is still in the list of containers however in this case the issue is that there is a dangling callback that was not cleared.
At the moment, I think you can workaround this by calling
radio.disconnect_events()
before removing theAxes
.
that helped. thanks everyone!
Bug summary
I am trying to remove some artists (
RadioButtons
andCheckButtons
) while keeping some others (axes with images), before exporting a figure to disk, and am running into this error:AttributeError: 'NoneType' object has no attribute 'canvas'
as MPL is trying to check if canvas for RadioButton has changed, although that RadioButton should not part of the equation at all as it was removed prior to trying to
.savefig()
Code for reproduction
Actual outcome
Expected outcome
smooth export with no error
Additional information
No response
Operating system
macOS 13
Matplotlib Version
3.7.1
Matplotlib Backend
TkAgg
Python version
3.11
Jupyter version
No response
Installation
pip