Created
April 21, 2019 22:50
-
-
Save BlitzKraft/e47be7ae7a0d78020425c890f96ea0d2 to your computer and use it in GitHub Desktop.
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
# 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