Skip to content

Instantly share code, notes, and snippets.

@heyalexej
Created August 15, 2015 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heyalexej/a1634da2da3cf1802f99 to your computer and use it in GitHub Desktop.
Save heyalexej/a1634da2da3cf1802f99 to your computer and use it in GitHub Desktop.
#!/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