处理Chaco的时间序列差距

Mar*_*219 14 python matplotlib chaco

我有一个标准的金融时间序列数据,这些数据在市场关闭时存在差距.

问题是Chaco显示了这些差距,我可以在matplotlib中使用格式化程序,如下所示并应用于x轴以解决这个问题,但我不确定在Chaco中我应该怎么做.

在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)
Run Code Online (Sandbox Code Playgroud)

在Chaco中实现这一目标的有效方法是什么?谢谢

Vir*_*hah 2

像这样传递参数

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