Closed
Description
#3835 ensured that the .axes
attribute of an artist cannot be assigned to a new Axes when it is already set to an earlier Axes. However, it does not prevent one from doing so by going via None. Also, nothing is done regarding reassignment of .figure
.
In practice there's plenty of code that assumes these invariants (see #6785 for how I ended up here), so I'd suggest tightening the restrictions to
.axes
can only ever be set to a non-None value once. Upon removal of the artist from an axes, the private attribute._discarded
is set to prevent further reuse. (If there is truly need for it, we could add a.copy()
method that would return, well, a copy of the artist, but with._discarded
unset, so that it can be reassigned to a new Axes.).figure
follows the same rules, and is additionally automatically set/unset whenever.axes
is set/unset.
Thoughts?
Metadata
Metadata
Assignees
Labels
Marked by the “Stale” Github ActionMarked by the “Stale” Github Action