Dealing with timeseries gaps in Chaco
Asked Answered
W

1

14

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

Westney answered 13/3, 2012 at 18:5 Comment(4)
With the caveat that I don't know Chaco, I expect that you'd want to use a 2D plot rather than an XY plot. The fundemental concept of an XY plot is that is to illustrate the relationship between continuous 'X" values. Just a guess, good luck!Gwennie
I can't see why this issue has been tagged as matplotlib?Sherris
see this question: #2174132Aquarius
Why don't you apply a mask to your data using numpy and then just plot the masked arrayArd
I
2

pass the parameters like this

from enthought.chaco.scales.formatters import TimeFormatter
TimeFormatter._formats['days'] = ('%d/%m', '%d%a',)
Isoniazid answered 19/7, 2012 at 14:8 Comment(1)
Generating a NAN series using Pandas Timeseries is another way to go [link] pandas.pydata.org/pandas-docs/stable/timeseries.html[/link].Westney

© 2022 - 2024 — McMap. All rights reserved.