plotting from a dictionary

Hey All,

I have a dictionary that maps date to a count (in this case the number of false negatives from my spam filter) and I'm wondering how to best plot something that looks like, say:

from datetime import date
data = {
   date(2008,03,01):10,
   date(2008,03,02):15,
   date(2008,03,03):13,
}

I'm worried about getting the dates out in order such that I get a straight line plot, rather than the zigzag back-and-forth line I reckon I'd get if I did:

dates = []
count = []
for date,count in data.items:
   dates.append(date)
   count.append(count)

plot(dates,counts)

cheers,

Chris

···

--
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk

Chris,

Why wouldn't you try to use sorted on your dictionary, construct an array from
the result of sorted, and get the corresponding columns ?

···

ddict={date(2008,01,01):10,date(2008,01,03):20,date(2008,01,02):30}
results=numpy.array(sorted(ddict.iteritems()),)
print results[:,0]
[2008-01-01 2008-01-02 2008-01-03]
print results[:,1]
[10 30 20]