Skip to content

Instantly share code, notes, and snippets.

@Seagor
Created April 6, 2016 19:57
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 Seagor/d7c8b69b2139982ce7992de147533725 to your computer and use it in GitHub Desktop.
Save Seagor/d7c8b69b2139982ce7992de147533725 to your computer and use it in GitHub Desktop.
%matplotlib inline
import matplotlib.pyplot as plt
from datetime import timedelta
from bson import ObjectId
import seaborn as sns
sns.set_style('whitegrid')
from itertools import cycle
cyclic_palette = cycle(sns.color_palette())
values = []
X = [ObjectId(oid).generation_time for oid, rec in data][:40]
ref = ""
current_color = cyclic_palette.next()
for oid, rec in data:
if rec['media']['__data__'] != ref:
current_color = cyclic_palette.next()
values.append(current_color)
ref = rec['media']['__data__']
values = values[:40]
fig, ax = plt.subplots(figsize=(18,2))
ax.scatter(X, [1]*len(X), c=values,
marker='s', s=100)
fig.autofmt_xdate()
# everything after this is turning off stuff that's plotted by default
ax.yaxis.set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.xaxis.set_ticks_position('bottom')
ax.get_yaxis().set_ticklabels([])
interval = timedelta(minutes=0)
plt.xlim(X[0] - interval, X[-1] + interval)
plt.title("Unique Images Captured via Polling")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment