Update offline iplot in ipython notebook

I want to refresh an offline interactive plot created in ipython notebook in a for loop, e.g.

import plotly.offline as pyo
from plotly import tools
import time


trace = go.Scatter(
    x=[1, 2, 3],
    y=[4, 5, 6]

fig = tools.make_subplots(rows=1, cols=1)

for i in range(10):
    trace = go.Scatter(
        x=[i, i+1, i+2],
        y=[4, 5, 6]

This, however, spits out a new interactive plot for each iteration of the for loop. I’d just like to update the first plot I create without spitting out 10 extra plots. How can I do this?

1 Like

Hi there,
Setting a filename will allow you to update a single plot. See this tutorial for more info: https://plot.ly/python/file-options/

Just adding the filename keyword argument to iplot still generates the extra plots. plotly.offline.iplot does not have the fileopt keyword argument that plotly.plotly.plot does, so I wasn’t sure how to get this to work with the offline iplot.

It would be really useful to be able to this! Did you figure it out eventually? Or is there no way to make this work offline?

i have the same problem and it seems there is no way out. but isn’t this is something very basic and should be available

this probably is a solution for online version only… not offline one

Would love to see this feature in offline mode. Using Dash to make this happen meanwhile

Yeah would be really nice! Or is there a workaround for this?

Hi @Varlor,

This is now possible in the Jupyter Notebook using the FigureWidget class introduced in plotly.py version 3. See https://github.com/plotly/plotly.py#installation for installation instructions. And see the Add Custom Interactivity with Jupyter Widgets documentation page for some example usage.

Hope that helps,

Perfect, thank you very much!!!

1 Like