Skip to content

Instantly share code, notes, and snippets.

Last active Apr 18, 2017
What would you like to do?
Todo.txt to graph
import matplotlib.pyplot as plt
import datetime
def get_stats(filename):
data = {}
with open(filename) as todofile:
for line in todofile:
date = line.split()[1]
if date in data:
data[date] += 1
data[date] = 1
return data
def get_last_days(days):
for day in range(days)[::-1]:
date = - datetime.timedelta(days=day)
plt.title("Todo.txt Progress")
plt.ylabel("Number of tasks done")
stats = get_stats("/home/leonardo/Sync/default/done.txt")
todoCounts = []
for date in get_last_days(15):
todoCounts.append(stats.get(date, 0))
plt.yticks(range(max(todoCounts) + 1))
plt.xticks(range(15), get_last_days(15), rotation=80)
plt.plot(todoCounts, marker="o")
plt.savefig("public/img/todo.jpeg", dpi=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment