matplotlib / matplotlib/ipympl
Closing a figure from the notebook does not close the python figure
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Jupyter Notebook
- Estrellas
- 1.7k
- Forks
- 234
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con js/src/mpl_widget.js, especialmente con la función de eliminación del DOM y el manejo del botón de cierre del widget descritos en el issue. Reproduce el problema ejecutando repetidamente la celda del gráfico y cerrando explícitamente el widget; después, verifica que el número de figuras, el uso de memoria y la advertencia de más de 20 figuras ya no sigan aumentando.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, jupyter-notebook, python
- Área
- backend, frontend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100