matplotlib / matplotlib/ipympl

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

オープン
#4 コメント 15 件 リアクション 8 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Jupyter Notebook
スター
1.7k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

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](https://github.com/matplotlib/jupyter-matplotlib/blob/master/js/src/mpl_widget.js#L122)
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](https://github.com/matplotlib/jupyter-matplotlib/blob/master/js/src/mpl_widget.js#L115) 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

js/src/mpl_widget.js から始め、特に issue で説明されている DOM からの削除関数とウィジェットの閉じるボタンの処理を確認します。プロットセルを繰り返し実行し、ウィジェットを明示的に閉じることで問題を再現してから、Figure の数、メモリ使用量、20 個を超える Figure に関する警告がこれ以上増加しないことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, jupyter-notebook, python
領域
backend, frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。