matplotlib / matplotlib/ipympl
Matplotlib figures are not redrawn in the cell in which they are created
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
Describe the issue
Using an interactive figure's canvas.draw() method does not update the figure if it was created in the same cell as the draw call.
Figure created in the same cell:

Figure created in another cell:

Reproduce
- Open a new notebook in JupyterLab or Notebook
- Insert the following code:
import matplotlib.pyplot as plt
import time
%matplotlib widget
fig = plt.figure()
for i in range(5):
x = list(range(i+2))
xx = [x**2 for x in x]
plt.clf()
plt.plot(x, xx)
fig.canvas.draw()
time.sleep(1)
- Run the cell and observe that the plot does not show until the loop has exited.
Optional:
- Move the for loop to a separate cell from the figure creation
- Run cell and observe plot updates during the loop
This can be reproduced using the scipy notebook docker stack.
Versions
3.8.5 | packaged by conda-forge | (default, Jul 31 2020, 02:39:48)
[GCC 7.5.0]
ipympl version: 0.5.7
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : not installed
ipython : 7.17.0
ipykernel : 5.3.4
jupyter client : 6.1.6
jupyter lab : 2.1.5
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.7
traitlets : 4.3.3
Known nbextensions:
config dir: /opt/conda/etc/jupyter/nbconfig
notebook section
jupyter-matplotlib/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
JupyterLab v2.1.5
Known labextensions:
app dir: /opt/conda/share/jupyter/lab
@bokeh/jupyter_bokeh v2.0.3 enabled OK
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK
jupyter-matplotlib v0.7.3 enabled OK
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
Commencez par exécuter la reproduction fournie dans la même cellule de JupyterLab ou Notebook avec le backend %matplotlib widget, puis comparez-la avec la version utilisant des cellules séparées. C’est terminé lorsque fig.canvas.draw() met visiblement à jour la figure à chaque itération de la boucle, au lieu de le faire uniquement après la fin de la boucle.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- jupyter-notebook, matplotlib, python
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100