matplotlib / matplotlib/ipympl

Failed to execute 'drawImage' on 'CanvasRenderingContext2D' when Canvas instance is embedded in the ipywidgets layout

Đang mở
#472 3 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ả

For my project, it is required to embed Canvas from the ipympl backend in the ipywidgets Layout or AppLayout.
It worked perfectly with version 0.7.0, but with all newer versions the plot image is not rendered in the canvas with exception in Crome browser: Error setting state: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.

The minimum example:

import numpy as np
from matplotlib.figure import Figure
from ipympl.backend_nbagg import Canvas as Canvas, FigureManager

class PlotWidget(Canvas):
    
    __num__ = 0
    
    def __init__(self, **kwargs):
        Canvas.__init__(self, Figure(dpi=100, figsize=(6, 5.5)))
        self.resizable = False
        self.header_visible=False
        
        fig = self.figure
        ax = fig.add_subplot(1, 1, 1)
        self.lines, = ax.plot(np.linspace(0, 1, 100), np.linspace(0, 1, 100), 'o-', markersize=2, linewidth=2)
        
        manager = FigureManager(self, self.__num__)
        self.__num__+=1
        self.draw()
    
import ipywidgets.widgets as widgets
from ipywidgets import AppLayout, Layout

class Layout(AppLayout):
    
    def __init__(self, **kwargs):
        AppLayout.__init__(self, **kwargs)
        self.center = PlotWidget(**kwargs)
        if "pane_widths" not in kwargs: 
            self.pane_widths = [1, '650px', '0px']
        if "pane_heights" not in kwargs: 
            self.pane_heights = ['0px', '300px', '0px']

app = Layout()
display(app)

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

Bắt đầu với ví dụ tối thiểu được cung cấp, sử dụng Canvas của backend_nbagg của ipympl bên trong một ipywidgets AppLayout, và tái hiện lỗi hình ảnh bị hỏng trong Chrome. So sánh hành vi giữa phiên bản 0.7.0 và các phiên bản mới hơn; hoàn tất khi biểu đồ được kết xuất trong canvas được nhúng mà không có ngoại lệ drawImage.

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, 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
38/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.