matplotlib / matplotlib/ipympl

Closing a figure from the notebook does not close the python figure

Aberta
#4 15 comentários 8 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Linguagem predominante
Jupyter Notebook
Estrelas
1.7k
Forks
234
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece por js/src/mpl_widget.js, especialmente pela função de remoção do DOM e pelo tratamento do botão de fechar do widget descritos na issue. Reproduza o problema executando repetidamente a célula do gráfico e fechando explicitamente o widget; em seguida, verifique se a contagem de figuras, o uso de memória e o aviso de mais de 20 figuras não continuam aumentando.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
javascript, jupyter-notebook, python
Domínio
backend, frontend
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.