Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with timeseries gaps in Chaco

I have a standard financial timeseries of data which has gaps for when the market is closed.

The problem is Chaco displays these gaps, I could use a formatter in matplotlib as follows and apply to the x-axis to get around this but I am unsure what I should do about this in Chaco.

In matplotlib:

class MyFormatter(Formatter):
    def __init__(self, dates, fmt='%Y-%m-%d %H:%M'):
        self.dates = dates
        self.fmt = fmt

    def __call__(self, x, pos=0):
        'Return the label for time x at position pos'
        ind = int(round(x))
        if ind>=len(self.dates) or ind<0: return ''

        return self.dates[ind].strftime(self.fmt)

What would be the efficient way to implement this in Chaco? Thanks

like image 536
Marcus1219 Avatar asked Mar 13 '12 18:03

Marcus1219


1 Answers

pass the parameters like this

from enthought.chaco.scales.formatters import TimeFormatter
TimeFormatter._formats['days'] = ('%d/%m', '%d%a',)
like image 180
Viral Shah Avatar answered Oct 01 '22 18:10

Viral Shah