Plotly dynamic graph


I am new to plotly and wanted to run a dynamic plot that updates during the execution of the program.

I am following this page Plotly figurewidget overview in Python and have this code;

import plotly.graph_objects as go

f = go.FigureWidget()

f.add_scatter(y=[2, 1, 4, 3]);
f.layout.title = ‘Hello FigureWidget’

– update scatter data
scatter =[0]
scatter.y = [3, 1, 4, 3]

however, nothing happens, there is no output.

I am running from Spyder or command line.

If I do plot(f) before and after update it then displays two plots in the browser.

How should this be done?

Hi @ruperty, welcome to the forum! The FigureWidget work only in a notebook environment (Jupyter or Jupyter lab), as the other widgets from ipywidgets for example (the reason is that you need a kernel listening to information Javascript may send back to Python). So you can’t use it from Spyder only. If you don’t want to work in a notebook you can write a Dash app.

Ok, thanks, it wasn’t clear from that page that it was only for notebooks.

Dash looks great, though somewhat more complex than I was looking for.