matplotlib / matplotlib/ipympl
Failed to execute 'drawImage' on 'CanvasRenderingContext2D' when Canvas instance is embedded in the ipywidgets layout
Personne n'a encore pris cette issue.
- Langage dominant
- Jupyter Notebook
- Étoiles
- 1.7k
- Forks
- 234
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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)
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, jupyter-notebook, matplotlib, python
- Domaine
- data-visualization, frontend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100