Cannot update FigureWidget in Jupyter notebook in real time

Windows 10
Python 3.7.4
jupyter 1.0.0
plotly 4.1.1

Trying to follow this example:

If I do this…

import plotly.graph_objects as go
f = go.FigureWidget()
f

…then what I get is this:

FigureWidget({
    'data': [], 'layout': {'template': '...'}
})

In order to actually display a figure, I need to do this instead:

import plotly.graph_objects as go
f = go.FigureWidget()
f.show()

An empty graph is then displayed. But then there’s no update later on.

I’ve tried some examples:

f.add_scatter(y=[2, 1, 4, 3]);
scatter = f.data[0]
scatter.y = [3, 1, 4, 3]

…but the figure is never updated, even when I use f.show()

What’s going on? What does it take to do live updates on a figure?

My ultimate goal is to draw a figure once, and then in a for loop to dynamically update the data that’s displayed.

Did you ever figure this out? Struggling with the same exact thing right now.

I do not remember what the solution was - or whether I’ve found it, actually. What I needed Plotly for, ultimately, was to draw heat maps: plot the intensity of some variable based on geolocation coordinates. In that, I was successful. Check this repo:

world.py and usa.py are the main apps. For multiprocessing, they launch multiple workers with code from workers.py - that’s where the Plotly code is. I have not looked at that code since I wrote it a while ago, so I don’t remember much off the top of my head.

Hope that helps.