matplotlib / matplotlib/ipympl

Displaying a previously created Matplotlib figure in a widget

Đang mở
#203 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

I'm trying to find a way to take a figure previously created, and show it inside a widget, without losing interactivity.
Here's a short version of my approach (which may not be the right one):

fig = plt.figure() # previously created figure
out = widgets.Output()
with out:
    display(fig)
# other things happening
display(widgets.HBox([fig.canvas, some_other_fig]))

If I first create a figure in the notebook outside of an Output widget, and then wish to include it later inside something like an HBox next to a second figure, I seem to lose interactivity with the figure (including the nice ipympl zoom interface).

Here is a nbviewer view of a MWE notebook I created, download it top right on the window. It's best if one downloads it and runs it since the first figure appears buggy in the nbviewer.

Additionally, and I might create a new issue for this - if I call fig1 at the end of the notebook, I get an unexpected error. Here I'd expect the regular figure to be shown. The error is AttributeError: 'NoneType' object has no attribute '_send_event'.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tải xuống và chạy Output Example Notebook được liên kết để tái hiện hành vi với figure đã tạo trước đó, Output widget và HBox. Bắt đầu bằng cách theo dõi cách figure được hiển thị và canvas của nó được xử lý, sau đó xác minh rằng figure vẫn giữ được tính tương tác của ipympl trong HBox và việc hiển thị fig1 không còn gây ra lỗi NoneType đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
jupyter-notebook, matplotlib, python
Lĩnh vực
data-visualization, 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.