matplotlib / matplotlib/ipympl
Closing a figure from the notebook does not close the python figure
还没有人认领这个 Issue。
- 主要语言
- 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
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 js/src/mpl_widget.js 开始,重点查看 issue 中描述的 DOM 移除函数和 widget 关闭按钮处理。通过反复执行绘图单元格并显式关闭 widget 来重现问题,然后确认 figure 数量、内存使用量以及超过 20 个 figure 的警告不再继续增加。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, jupyter-notebook, python
- 领域
- backend, frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100