matplotlib / matplotlib/ipympl
What prevents a figure showing before notebook cell completion?
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
My issue boils down to:
"Why does the figure not show immediately, but instead waits until the cell has completed running?"
```python
%matplotlib widget
import matplotlib.pyplot as plt
from time import sleep
fig = plt.figure()
plt.plot([1,2,3])
sleep(2)
```

This behaviour is preventing fun uses, like dynamic plotting in a single cell:
```python
%matplotlib widget
from matplotlib import pyplot as plt
from time import sleep
import numpy as np
fig = plt.figure()
for i in range(10):
x, y = np.random.random(2)
plt.scatter(x, y)
fig.canvas.draw()
sleep(0.1)
```
The previous code works if one splits it into two cells, placing the `figure()` call in the first one:
```python
# Cell 1
%matplotlib widget
from matplotlib import pyplot as plt
from time import sleep
import numpy as np
fig = plt.figure()
# Cell 2
for i in range(10):
x, y = np.random.random(2)
plt.scatter(x, y)
fig.canvas.draw()
sleep(0.1)
```

Edit: I also note that in the qt backend, there figure and plot are shown immediately, in contrast to the ipympl behaviour.
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
Der Issue nennt keine Quelldateien oder Tests. Beginne damit, die Beispiele mit einer einzelnen Zelle und mit aufgeteilten Zellen mit dem Backend `%matplotlib widget` zu reproduzieren, und vergleiche dann das Verhalten von `fig.canvas.draw()` mit dem Qt-Backend; als erledigt gilt die Aufgabe, wenn die Ursache und ein angemessenes Rendering-Verhalten festgestellt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- jupyter, jupyter-notebook, python
- Bereich
- data-visualization, frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100