Created
March 19, 2015 21:25
-
-
Save theengineear/a6f69c5e81ed2389aacc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import plotly.plotly as py\n", | |
"from plotly.graph_objs import *" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"token0 = py.get_credentials()['stream_ids'][0] # make sure not to print tokens in plain text\n", | |
"token1 = py.get_credentials()['stream_ids'][1]\n", | |
"token2 = py.get_credentials()['stream_ids'][2]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~theengineear/3269.embed\" height=\"525\" width=\"100%\"></iframe>" | |
], | |
"text/plain": [ | |
"<plotly.tools.PlotlyDisplay object>" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fig = Figure()\n", | |
"fig['data'].append(Histogram(stream=Stream(token=token0)))\n", | |
"fig['data'].append(Scatter(x=[], y=[], stream=Stream(token=token1)))\n", | |
"fig['data'].append(Scatter(x=[], y=[], stream=Stream(token=token2)))\n", | |
"py.iplot(fig, filename='multi-trace-stream')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"import time\n", | |
"s0 = py.Stream(token0)\n", | |
"s1 = py.Stream(token1)\n", | |
"s2 = py.Stream(token2)\n", | |
"s0.open()\n", | |
"s1.open()\n", | |
"s2.open()\n", | |
"for i in range(10):\n", | |
" if i == 0:\n", | |
" s0.write(Histogram(x=[i]))\n", | |
" time.sleep(.1)\n", | |
" s1.write(Scatter(x=[i], y=[i+1]))\n", | |
" time.sleep(.1)\n", | |
" s2.write(Scatter(x=[10-i], y=[-i]))\n", | |
" time.sleep(.1)\n", | |
" else:\n", | |
" s0.write(Histogram(x=i))\n", | |
" time.sleep(.1)\n", | |
" s1.write(Scatter(x=i, y=i+1))\n", | |
" time.sleep(.1)\n", | |
" s2.write(Scatter(x=10-i, y=-i))\n", | |
" time.sleep(.1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.8" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment