You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH]: Remove artists from axes completely. #25168
Calling art.remove() doesn't seem to completely detach the art from the original axes.
In the following sample code, when removing the art from axes (say ax1) and adding it to other axes (say ax2), the ax2 will not draw the art.
I think the second solution makes sense, and it not being set False almost seems like a bug. @komoto48g do you have bandwidth for a PR? The tricky part is that it will probably require a test.
Anyone else understand the artist removal procedures well enough to comment if this makes sense? It seems correct to me...
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Do we want/need to guarantee that an artist that has been removed can be re-added? Is there a use case? We could alternatively explicitly document that this is not supported and users should create a new Artist if they need it again.
Since we've now made it so that Figure can be re-opened/re-attached to a GUI, it does seem like re-usability isn't unexpected. I don't have a particular use case or idea of the scope of work to guarantee this ability though, while @tacaswell already has the PR made to disallow it.
Switching backends of figures / attaching/detaching from pyplot is conceptually different than removing and attaching artists. I would not say that one justifiably gives rise to expectations on the other. The critical point with reusability is that state management has to be clean, in particular:
clearly decide which properties should be set on __init__, because that does only happen once
ensure removal cleans up all dependencies, not only refrences, but also state that was set based on the Figure/Axes
ensure reattaching wires all need dependencies
We can of course, implement this, but it will be a substantial effort. The existing code was not written with that in mind, and I suppose there are quite a number of traps. As an example, take this code, which is called as part of add_artist():
Activity
jklymak commentedon Feb 7, 2023
I think the second solution makes sense, and it not being set False almost seems like a bug. @komoto48g do you have bandwidth for a PR? The tricky part is that it will probably require a test.
Anyone else understand the artist removal procedures well enough to comment if this makes sense? It seems correct to me...
komoto48g commentedon Feb 8, 2023
Thank you for the advice. Sure. I will make this PR this weekend.
tacaswell commentedon Feb 13, 2023
#24626 is an alternate approach. I am actually surprised that this does not raise...
github-actions commentedon Apr 13, 2026
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
timhoffm commentedon Apr 13, 2026
Do we want/need to guarantee that an artist that has been removed can be re-added? Is there a use case? We could alternatively explicitly document that this is not supported and users should create a new Artist if they need it again.
QuLogic commentedon Apr 17, 2026
Since we've now made it so that
Figurecan be re-opened/re-attached to a GUI, it does seem like re-usability isn't unexpected. I don't have a particular use case or idea of the scope of work to guarantee this ability though, while @tacaswell already has the PR made to disallow it.timhoffm commentedon Apr 17, 2026
Switching backends of figures / attaching/detaching from pyplot is conceptually different than removing and attaching artists. I would not say that one justifiably gives rise to expectations on the other. The critical point with reusability is that state management has to be clean, in particular:
__init__, because that does only happen onceWe can of course, implement this, but it will be a substantial effort. The existing code was not written with that in mind, and I suppose there are quite a number of traps. As an example, take this code, which is called as part of
add_artist():matplotlib/lib/matplotlib/axes/_base.py
Lines 1233 to 1234 in 1392cbe
I am of the opinion that this is not a priority and not worth the effort.