Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
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
.axescan only ever be set to a non-None value once. Upon removal of the artist from an axes, the private attribute._discardedis 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._discardedunset, so that it can be reassigned to a new Axes.).figurefollows the same rules, and is additionally automatically set/unset whenever.axesis set/unset.
Thoughts?