matplotlib / matplotlib/ipympl
Failed to execute 'drawImage' on 'CanvasRenderingContext2D' when Canvas instance is embedded in the ipywidgets layout
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 1.7k
- Forks
- 234
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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)
```
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, jupyter-notebook, matplotlib, python
- Bereich
- data-visualization, frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100