2
我想添加標記到我的散景圖中,這裏是我的示例代碼,信號表具有值1和0的位置列,如果位置== 1我需要將標記添加到我的TimeSeries圖表。我如何做到這一點,而不使用傳統的matplotlib繪圖,而只是使用Bokeh界面?散景圖上的多個圖表
def bokeh_chart(symbol, bars, signals, returns):
xyvalues = pd.DataFrame({
"Price": bars['Close'],
"Date": bars.index.values,
"short_mavg": signals['short_mavg'],
"long_mavg": signals['long_mavg']})
pt = TimeSeries(xyvalues, index='Date', legend=True,
title=symbol , ylabel='Stock Prices', width=400, height=200)
#for Scatter, is it possible to be have a dataframe for x and y parameter (1st and 2nd parameters in the function below)?
p = Scatter(signals, signals.ix[signals.positions == 1.0].index, signals.short_mavg[signals.positions == 1.0], marker='triangle')
script,div=components(p)
return {"script":script, "div":div}
從Bokeh'0.12'(今天發佈)開始'Charts'具有所有相同的字形函數(例如,'circle','line'),並且可以用來直接在圖表上繪製。 – bigreddot