Hi, I have time data stored in the format hh:mm:ss and

> would like to plot it, having about 4 to 6 ticks labeled

> in this format. What I'm doing at the moment is to

> first convert my time to seconds and plot y as function

> of yime in seconds.

You first need to convert them to matplotlib dates. Assume your data

are collected on Oct 10th, 2006

import matplotlib.numerix as nx

import datetime

from matplotlib.dates import date2num, MINUTES_PER_DAY, SEC_PER_DAY

d0 = date2num(datetime.date(2006,10,10))

def convert(s):

h,m,s = map(float, s.split(':'))

return d0 + h/24. + m/MINUTES_PER_DAY + s/SEC_PER_DAY

In [11]: convert('12:32:02')

Out[11]: 732594.52224537032

matplotlib represents dates as days (float) since 0000-00-00

Now you need to convert your list of strings to mpl dates. If your

list of strings is called datestrs

dates = nx.array([convert(s) for s in datestrs])

Now when you plot you need to tell mpl you are plotting dates

ax.plot_date(dates, vals)

We have pretty smart tick locators and tick formatters for date

plotting, so you may be happy with what you get, but if not you can

set your own

from matplotlib.dates import DateFormatter

ax.xaxis.set_major_formatter('%H:%M:%S')

I also find it helpful on date plots to do the following

# move the subplot up a bit to make for rotated labels

fig.subplots_adjust(bottom=0.15)

for label in ax.get_xticklabels():

label.set_rotation(30)

label.set_horizontalalignment('right')

see also

http://matplotlib.sf.net/matplotlib.dates.html

http://matplotlib.sf.net/matplotlib.ticker.html

the users guide and the following examples

date_demo1.py

date_demo2.py

date_demo_convert.py

date_demo_rrule.py

finance_demo.py

JDH