Created
August 15, 2015 18:37
-
-
Save heyalexej/a1634da2da3cf1802f99 to your computer and use it in GitHub Desktop.
plotly solution for https://gist.github.com/christiandietrich/79051bbd582b96a93a2e
This file contains hidden or 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
#!/usr/bin/python | |
import plotly.plotly as py | |
from plotly.graph_objs import * | |
import datetime as dt | |
import csv | |
py.sign_in('user', 'pass') | |
# Visualize CSV Data | |
with open('res.csv', 'rb') as f: | |
reader = csv.reader(f, delimiter=',') | |
subreddit = [] | |
readers = [] | |
active = [] | |
timestamp = [] | |
for row in reader: | |
subreddit.append(row[0]) | |
readers.append(int(row[1])) | |
active.append(int(row[2])) | |
timestamp.append(dt.datetime.fromtimestamp(int(row[3]))) | |
# print subreddit, readers, active, timestamp # for debug | |
active = Scatter( | |
x=timestamp, | |
y=active, | |
name='active' | |
) | |
readers = Scatter( | |
x=timestamp, | |
y=readers, | |
name='readers' | |
) | |
# data = Data([active, readers]) # the universe explodes! | |
data = Data([active]) | |
layout = Layout( | |
xaxis=XAxis( | |
range=[ | |
min(timestamp), | |
max(timestamp) | |
] | |
) | |
) | |
fig = Figure(data=data, layout=layout) | |
plot_url = py.plot(fig, filename='python-datetime-custom-ranges') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment