-
Notifications
You must be signed in to change notification settings - Fork 231
Open
Description
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 updateThis 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)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels