matplotlib / matplotlib/ipympl
What prevents a figure showing before notebook cell completion?
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Jupyter Notebook
- Estrellas
- 1.7k
- Forks
- 234
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
El issue no menciona archivos fuente ni tests. Empieza reproduciendo los ejemplos de una sola celda y de celdas divididas con el backend `%matplotlib widget` y, después, compara el comportamiento de `fig.canvas.draw()` con el backend de Qt; se considera terminado cuando se hayan establecido la causa y un comportamiento de renderizado adecuado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- jupyter, jupyter-notebook, python
- Área
- data-visualization, frontend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100