|
From: Peter G. <pgr...@ge...> - 2004-05-27 03:57:29
|
Hi:
I was wondering whether anyone else has noticed a performance difference
between using plot_date() and plot().
Here is a dummy script:
#!/usr/bin/env python
import time
from matplotlib.dates import EpochConverter
from matplotlib.matlab import *
from matplotlib.ticker import DateFormatter, DayLocator, HourLocator
useDates=0
now=time.time()
weekAgo=now-60*60*24*7
dates=arange(weekAgo, now, 10) #Say have a point every 10 secs..
vals=dates
if useDates:
#Date plot
fmt=DateFormatter('%D')
days=DayLocator(1)
hours=HourLocator(12)
converter = EpochConverter()
ax = subplot(111)
plot_date(dates, vals, converter)
ax.xaxis.set_major_locator(days)
ax.xaxis.set_major_formatter(fmt)
ax.xaxis.set_minor_locator(hours)
#What will this do??
#ax.autoscale_view()
else:
#Regular plot
plot(dates, vals)
ylabel('Number of points: '+str(len(dates)))
xlabel('time')
grid(True)
show()
I use python2.2 running on a 3.2 PIV with 2GB or ram and when I use
regular plotting, this takes ~1sec. With plot_date() it takes ~8sec.
I really like the flexibility of the way dates are handled but this
seems to be too much of a performance hit for me to use (I ofter have
data sets of 500 000 points). So my question is whether I am perhaps
missing something trivial and not setting things up right. I cannot run
any of the date_demo scripts because don't have python2.3 so cannot test
how fast they run.
I will need to setup the x-axis labeling as dates, but now it seems it
would be faster to just update the xticslabels of a "regular" plot.
Any thoughts?
Thanks.
--
Peter Groszkowski Gemini Observatory
Tel: +1 808 974-2509 670 N. A'ohoku Place
Fax: +1 808 935-9235 Hilo, Hawai'i 96720, USA
|