# Initialize your plotly real-time streaming graph with a REST API call

# Embed your stream token in one of the traces of a plotly-data object - one token per trace

# Also embed 'maxpoints', the number of points that you want plotted at a time

# The `iplot` command will embed our plotly graph as an iframe in this notebook

# Each plotly graph has a unique url that you can share

# Anyone can view your streaming graph in real-time -

# viewers see the same data at the same time

# (try it! Open up this notebook up in two different browser windows and observer

# that the graphs are plotting identical data!)

# The unique URL for this graph is https://plot.ly/~streaming-demos/4

def

axes

(

range

):

return

{

"autotick"

:

True

,

"showgrid"

:

False

,

"showline"

:

False

,

"zeroline"

:

False

,

"ticks"

:

''

,

"range"

:

range

}

p

.

iplot

([

{

'x'

:

[],

'y'

:

[],

'type'

:

'scatter'

,

'mode'

:

'lines+markers'

,

'line'

:

{

'opacity'

:

0.8

},

'marker'

:

{

'size'

:

12

},

'stream'

:

{

'token'

:

stream_tokens

[

4

],

}

},

{

'x'

:

[],

'y'

:

[],

'type'

:

'scatter'

,

'mode'

:

'lines'

,

'line'

:

{

'color'

:

'rgba(31, 119, 180, 0.15)'

},

'stream'

:

{

'token'

:

stream_tokens

[

5

],

'maxpoints'

:

100

}

}],

layout

=

{

'xaxis'

:

axes

([

-

2

,

2

]),

'yaxis'

:

axes

([

-

2

,

0.5

]),

'title'

:

'Double Pendulum Simulation'

,

'showlegend'

:

False

},

filename

=

'streaming double pendulum'

,

fileopt

=

'overwrite'

)