我们假设您的时间序列超过1000天。以下是如何在pannable(单击并拖动)和zoomable(时间x轴和y轴值)中绘制它:
import pandas as pd
import datetime
import math
import matplotlib.pyplot as plt
N = 1000
df = pd.DataFrame(columns = ['y'])
start = datetime.datetime.now() - datetime.timedelta(days = N)
for i in range(N):
t = start + datetime.timedelta(days = i)
df.ix[t] = {'y': math.sin(0.1 * i)} # btw, is there a simpler way? I tried df.ix[t]['y'] = ... but unsuccessfully
df.plot()
plt.show()
但是这个UI缺少一些功能,使它看起来像realtime-updating trading chart,例如: