matplotlib / matplotlib/ipympl

Need to create and update figures in seperate cells?

Abierto
#425 7 comentarios 0 reacciones 0 asignados Ver en GitHub

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

Something I've seen in previous versions as well as the current version: In order to have a figure that dynamically updates while some code is executing (e.g. tracking the loss function of an optimization), I have to create the figure in a separate jupyter notebook cell and run it before a I run the code that updates. If I don't do this, then a blank figure shows and never updates. I'm using Jupyter lab. Wondering if I'm doing something wrong here? It would make the code cleaner and easier to run if it could all be put in a single cell.

Example:

Using the following function:

def update_function(fig, ax):
   while True:
       # Do some computation
       ax.clear() #clear previously drawn
       ax.plot(some_data)
       fig.canvas.draw() #force it to update

This works:

# cell 1
fig, ax = plt.subplots()
# cell 2
update_function(fig, ax)

But this does not:

# one combined cell
fig, ax = plt.subplots()
update_function(fig, ax)

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

El issue no menciona archivos ni pruebas del repositorio. Empieza reproduciendo en JupyterLab los ejemplos con celdas separadas y celdas combinadas; después, compara cómo afecta update_function, de larga duración, al renderizado. Se considera terminado cuando la celda combinada actualiza la figura según lo solicitado, o cuando el issue documenta una limitación confirmada y su workaround correcto.

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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.