matplotlib / matplotlib/ipympl
Closing a figure from the notebook does not close the python figure
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 1.7k
- Forks
- 234
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
This is essentially a regression of https://github.com/matplotlib/matplotlib/issues/4841 which happened when the nbagg backend was converted to a widget.
To reproduce create a cell with a simple plot.
plt.plot(range(10))
plt.show()
re execute the cell and observe that the figure count goes up and memory consumption goes up too. If you continue doing this you will eventually have more than 20 open figures and matplotlib will print a warning even if you only have one figure displayed.
The same is true if you explicitly close the widget using the widget close cross on the left of the figure.
I have spent some time trying to figure out how to best fix this but don't really know how to best do this. This function
is meant to trigger a close message to the python side when the figure is removed from the DOM but no longer works.
The old no longer existing close button is also intended to send a close signal to the python layer but this is not hooked up to the widget close button.
https://github.com/matplotlib/matplotlib/issues/6414 has some more related issues.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit js/src/mpl_widget.js, insbesondere mit der im Issue beschriebenen Funktion zum Entfernen aus dem DOM und der Behandlung der Schaltfläche zum Schließen des Widgets. Reproduziere das Problem, indem du die Plot-Zelle wiederholt ausführst und das Widget ausdrücklich schließt, und überprüfe anschließend, dass die Anzahl der Figures, die Speichernutzung und die Warnung bei mehr als 20 Figures nicht weiter zunehmen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, jupyter-notebook, python
- Bereich
- backend, frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100