Skip to content

Instantly share code, notes, and snippets.

@thegreatshasha
Created December 9, 2015 18:46
Show Gist options
  • Save thegreatshasha/e94a3c5b949c8902c4ba to your computer and use it in GitHub Desktop.
Save thegreatshasha/e94a3c5b949c8902c4ba to your computer and use it in GitHub Desktop.
Plotly wrapper
import plotly.plotly as p
import datetime
import time
import numpy as np
import json
from plotly.graph_objs import *
import timeit
class Plotter:
def __init__(self):
self.config = {
'username': 'YOUR_USERNAME',
'api_key': 'YOUR_API',
'streaming_token': 'YOUR_STREAMING_TOKEN'
}
self.plot = p.iplot([{'x': [], 'y': [], 'type': 'scatter', 'mode': 'lines+markers',
'stream': {'token': self.config['streaming_token'], 'maxpoints': 80}
}],
filename='Time-Series', fileopt='overwrite')
self.url = self.plot.resource
print self.url
self.stream = p.Stream(self.config['streaming_token'])
self.stream.open()
def write(self, x, y):
self.stream.write({'x': x, 'y': y})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment