Re: why DateListPlot is so slow?
- To: mathgroup at smc.vnet.net
- Subject: [mg79933] Re: [mg79889] why DateListPlot is so slow?
- From: Darren Glosemeyer <darreng at wolfram.com>
- Date: Thu, 9 Aug 2007 05:16:54 -0400 (EDT)
- References: <200708080847.EAA05756@smc.vnet.net>
Arkadiusz.Majka at gmail.com wrote:
> Hi,
>
> I have a list (a time series):
>
> data={{00:00:30,x1},{00:01:00,x2},{00:01:30,x3},....}
>
> at equally spaced time intervals (30 seconds). The length od data is
> 8100 (24 h)
>
> DateListPlot[data] works fine but takes 28 sec, since
> ListPlot[data[[All,2]]] does it in less than 0.1 sec....
>
> Can you explain me why DateListPlot is so time consuming? Can we
> improve it?
>
> Best,
>
> Arek
>
>
Each of the date strings in the input data needs to be interpreted, and
this is where most of the time is spent.
In[1]:= times = Table[
DateString[{2007, 8, 8, 0, 0, 30*i}, {"Hour", ":", "Minute",
":",
"Second"}], {i, 8100}];
In[2]:= Map[DateList, times]; // Timing
Out[2]= {32.516, Null}
In[3]:= DateListPlot[Transpose[{times, Range[8100]}]]; // Timing
Out[3]= {33.453, Null}
If the date coordinates are specified as date lists, the plotting will
be much faster.
In[4]:= data = Transpose[{Table[
DateList[{2007, 8, 8, 0, 0, 30*i}], {i, 8100}], Range[8100]}];
In[5]:= DateListPlot[data]; // Timing
Out[5]= {0.609, Null}
DateListPlot will still be slower than ListPlot because there is still
some overhead in working with dates, but the timing difference will not
be as large if the dates in the data are specified as date lists.
In[6]:= ListPlot[data[[All, 2]]]; // Timing
Out[6]= {0.219, Null}
Darren Glosemeyer
Wolfram Research
- References:
- why DateListPlot is so slow?
- From: Arkadiusz.Majka@gmail.com
- why DateListPlot is so slow?