gpt4 book ai didi

python - 处理 Chaco 中的时间序列间隙

转载 作者:太空狗 更新时间:2023-10-29 17:20:52 26 4
gpt4 key购买 nike

我有一个标准的金融时间序列数据,其中包含市场收盘时的缺口。

问题是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)

在 Chaco 中实现它的有效方法是什么?谢谢

最佳答案

像这样传递参数

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

关于python - 处理 Chaco 中的时间序列间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9689586/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com