Created
December 9, 2015 18:46
-
-
Save thegreatshasha/e94a3c5b949c8902c4ba to your computer and use it in GitHub Desktop.
Plotly wrapper
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
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