From: John H. <jdh...@ac...> - 2005-01-23 02:34:26
|
>>>>> "Stephen" == Stephen Walton <ste...@cs...> writes: Stephen> I need a function which will take an N by 3 or N by 6 Stephen> array, where the columns are year, month, day in the Stephen> first case and those three plus hours, minutes, and Stephen> seconds in the second case and convert them to matplotlib Stephen> dates. This would work the same as the MATLAB datenum() Stephen> function. Hi Stephen, How about from datetime import datetime from pylab import date2num x = ...your array dts = date2num([ datetime(y,m,d) for y,m,d in x ]) or for the Nx6 case dts = date2num([ datetime(y,m,d,h,min,s) for y,m,d,h,min,s in x ]) or more succinctly dts = date2num([ datetime(*date) for date in x ]) FYI, date2num is found in matplotlib.dates. I'll take a look at the matlab datenum docstring in matlab and see about including this functionality in the matplotlib.dates version. Cheers, JDH |