Generating plots using FigureWidget in a for loop


I’m rewriting some existing code in Jupyter notebooks to leverage the 3.x APIs. I’m following the migration guide ( In the example:

import plotly import plotly.graph_objs as go
f = go.FigureWidget()
f # printing the widget will display it

“This means that plotly.offline.iplot and plotly.offline.init_notebook_mode() are no longer required (although still supported).”

It states that iplot is no longer required. I’m generating plots in a for loop and was previously using iplot for this. If I just “print” the figure object is indicated above, the plots don’t appear.

What’s the proper method in 3.x to display FigureWidget plots from a loop?

Hi @argoneus,

You can display FigureWidgets inside a loop (or function) using the IPython display method: See

Hope that helps!

1 Like

I tried using display(), but received the error:

Error displaying widget

I installed plotlywidget@0.4.0 and it’s working now. Thanks!

1 Like