matplotlib / matplotlib/ipympl

Displaying a previously created Matplotlib figure in a widget

Aperta
#203 8 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

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):

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 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'.

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

Scarica ed esegui l’Output Example Notebook collegato per riprodurre il comportamento con la figura creata in precedenza, l’Output widget e HBox. Inizia tracciando come vengono gestiti la figura visualizzata e il relativo canvas, quindi verifica che la figura mantenga l’interattività di ipympl in HBox e che la visualizzazione di fig1 non sollevi più l’errore NoneType segnalato.

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

Valutazione

Stack tecnologico
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
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.