Skip to content

Instantly share code, notes, and snippets.

@induhub
Created July 16, 2014 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save induhub/8754117e702c4cc542d0 to your computer and use it in GitHub Desktop.
Save induhub/8754117e702c4cc542d0 to your computer and use it in GitHub Desktop.
plotly_stream.py
import plotly.plotly as py
from plotly.graph_objs import Figure,Data,Scatter
from random import randint
import time
t=1
my_data = Data([Scatter(x=[],y=[],
stream=dict(token='akxp47t0xu'))])
my_fig = Figure(data=my_data)
py.plot(my_fig)
s = py.Stream('akxp47t0xu')
s.open()
while True:
p = randint(1,9)
s.write(dict(x=t+1,y=p))
t= t+1
time.sleep(1)
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment