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
pyo.init_notebook_mode(connected=True)
trace = go.Scatter(
x=[1, 2, 3],
y=[4, 5, 6]
)
fig = tools.make_subplots(rows=1, cols=1)
fig['data'].append(trace)
pyo.iplot(fig)
for i in range(10):
time.sleep(1)
trace = go.Scatter(
x=[i, i+1, i+2],
y=[4, 5, 6]
)
fig['data'].update(trace)
pyo.iplot(fig)
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?
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.