medhelp sleep graph replacement using python

In other words, graphing time of day versus date in python.

This morning I logged on to only to see that it had gone from somewhat usable for my purposes:

from my previous post,

where I can at least type in the times to some extent, even if there is no batch input (e.g. uploading a text file), to

wtf is this? i am clearly not in their target demographic…

So I decided to get up off my lazy butt and do some python plotting.

This is the end result:

(it’s flipped, so time increases going upward like you would expect a graph to do but opposite of how you would read the medhelp graph, where time increases going downwards, which I feel makes more intuitive sense).

The code is here:

I keep track of my sleep in a google doc that I just downloaded as a csv file. See the github repo.


brain/linkdump as i was working out how to do this

can set line width but the plot does not adjust to this (how to pad the dates out so the lines won’t ever overlap?)

unix time

bar plot
 now just need to adjust so not height, but also have start time

x = ‘3/18/2013’

x = 1365739200
# datetime.datetime(2013, 4, 12, 0, 0)
dates.DateFormatter(‘%B %d, %Y’) # January 16, 1970
okay, this solves the y-axis problem! excellent.
In particular,genfromtxt is able to take missing data into account, when other faster and simpler functions like loadtxt cannot

does not deal well with quotation marks in data
“Line #31 (got 8 columns instead of 7)”

24:00 –> 0:00:00 else

ValueError: time data '3/18/2013 24:00:00' does not match format '%m/%d/%Y %H:%M:%S'

also does not like 0 instead of 0:00:00