matplotlib / matplotlib/ipympl

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

Aperta
#472 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Jupyter Notebook
Stelle
1.7k
Fork
234
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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)

```

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Start with the provided minimum example using ipympl's backend_nbagg Canvas inside an ipywidgets AppLayout, and reproduce the broken-image error in Chrome. Compare behavior between version 0.7.0 and newer versions; done means the plot renders in the embedded canvas without the drawImage exception.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, jupyter-notebook, matplotlib, python
Ambito
data-visualization, frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.