Search code examples
pythonmatplotlibchaco

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


Solution

  • pass the parameters like this

    from enthought.chaco.scales.formatters import TimeFormatter
    TimeFormatter._formats['days'] = ('%d/%m', '%d%a',)