Skip to content

Instantly share code, notes, and snippets.

@BlitzKraft
Created April 21, 2019 22:50
Show Gist options
  • Save BlitzKraft/e47be7ae7a0d78020425c890f96ea0d2 to your computer and use it in GitHub Desktop.
Save BlitzKraft/e47be7ae7a0d78020425c890f96ea0d2 to your computer and use it in GitHub Desktop.
# number of comics read per week
READ_COMICS = 400
# number of comics released per week
RELEASED_COMICS = 3
START = 1700
END = 2140
import random
import matplotlib
matplotlib.use('agg')
from matplotlib import pyplot as plt
def get_week(start=START, count_dict={}):
if start < END:
sample = random.sample(range(1, start), READ_COMICS)
for index in sample:
count = count_dict.get(index, 0)
count_dict.update({index: count + 1})
start += RELEASED_COMICS
get_week(start, count_dict)
return count_dict
def draw_graph(count={}):
plt.xkcd()
plt.figure(figsize=(12,6), dpi=100)
plt.scatter(count.keys(), count.values())
plt.savefig('graph.png')
counts_per_comic = get_week()
draw_graph(counts_per_comic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment