我有一组标准的金融时间序列数据,其中包含市场关闭时的间隙。
问题是,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 中高效地实现这个功能?谢谢。
numpy
对数据应用 掩码,然后只需绘制掩码数组即可。 - abdulhaq-e