Skip to content

Instantly share code, notes, and snippets.

@heyalexej
Created August 15, 2015 18:02
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/97ad2107f16c6b9809ca to your computer and use it in GitHub Desktop.
Save heyalexej/97ad2107f16c6b9809ca to your computer and use it in GitHub Desktop.
#!/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