matplotlib / matplotlib/ipympl
Closing a figure from the notebook does not close the python figure
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 1.7k
- Fork
- 234
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với js/src/mpl_widget.js, đặc biệt là hàm xóa khỏi DOM và phần xử lý nút đóng widget được mô tả trong issue. Tái hiện sự cố bằng cách thực thi ô biểu đồ lặp đi lặp lại và đóng widget một cách rõ ràng, sau đó xác minh rằng số lượng figure, mức sử dụng bộ nhớ và cảnh báo về hơn 20 figure không còn tăng nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, jupyter-notebook, python
- Lĩnh vực
- backend, frontend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100