matplotlib / matplotlib/ipympl
Displaying a previously created Matplotlib figure in a widget
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
I'm trying to find a way to take a figure previously created, and show it inside a widget, _without losing interactivity._
Here's a short version of my approach (which may not be the right one):
```python
fig = plt.figure() # previously created figure
out = widgets.Output()
with out:
display(fig)
# other things happening
display(widgets.HBox([fig.canvas, some_other_fig]))
```
If I first create a figure in the notebook outside of an `Output` widget, and then wish to include it later inside something like an `HBox` next to a second figure, I seem to lose interactivity with the figure (including the nice ipympl zoom interface).
Here is a [nbviewer view](https://nbviewer.jupyter.org/github/thomasaarholt/tests/blob/master/Output%20Example%20Notebook.ipynb) of a MWE notebook I created, download it top right on the window. It's best if one downloads it and runs it since the first figure appears buggy in the nbviewer.
Additionally, and I might create a new issue for this - if I call `fig1` at the end of the notebook, I get an unexpected error. Here I'd expect the regular figure to be shown. The error is `AttributeError: 'NoneType' object has no attribute '_send_event'`.
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
Téléchargez et exécutez le Output Example Notebook lié afin de reproduire le comportement avec la figure créée précédemment, le Output widget et HBox. Commencez par retracer la manière dont la figure affichée et son canvas sont gérés, puis vérifiez que la figure conserve son interactivité ipympl dans HBox et que l’affichage de fig1 ne lève plus l’erreur NoneType signalée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- 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
- 35/100