Created
August 15, 2015 18:02
-
-
Save heyalexej/97ad2107f16c6b9809ca to your computer and use it in GitHub Desktop.
possible 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 | |
from matplotlib import pyplot as plt | |
import matplotlib.dates as md | |
import datetime as dt | |
import csv | |
# 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 | |
plt.xticks(rotation=25) | |
ax=plt.gca() | |
xfmt = md.DateFormatter('%Y-%m-%d %H:%M:%S') | |
plt.plot(timestamp, active) | |
ax.xaxis.set_major_formatter(xfmt) | |
plt.title("Active Users in Subreddit") | |
# add a label to the y-axis | |
plt.ylabel("Users") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment