[SciPy-user] Converting arrays to dates for plot_date()

Dharhas Pothina Dharhas.Pothina at twdb.state.tx.us
Thu May 1 16:15:08 EDT 2008


Hi,

I'm sure there is a simple way to do this that I'm missing. I'm coming form a matlab background and am still having trouble understanding the interactions between arrays and lists etc

I have a file with time series data

1986 7 8 32.1
1986 7 9 42.5
1986 7 10 22.2
...

I've read this in using loadtxt to the arrays : year,month,day & data

What I want to do is use matplotlibs plot_date() command to plot the data against the date.

I've worked out that I can use something like

datestr2num(['2006-01-01','2006-01-02'])

to generate the list of dates for plot_date()

but I can't work out how to convert 

year = array([2006.0,2007.0])
month = array([11,12])
day = array([1,2])

into the form

datestring = array(['2006-11-1','2007-12-2'])

I've also tried using the datetime() function but I've worked out that doesn't work with numpy arrays.

any pointers/help would be greatly appreciated.

thanks,

- dharhas




More information about the SciPy-User mailing list