简体   繁体   English

处理Chaco中的时间序列差异

[英]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. 问题是Chaco显示了这些差距,我可以按照以下方式在matplotlib中使用格式化程序,并应用于x轴来解决此问题,但是我不确定我应该在Chaco中对此做些什么。

In matplotlib: 在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? 在Chaco中实现此目标的有效方法是什么? Thanks 谢谢

pass the parameters like this 像这样传递参数

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM