2017-06-13 20 views
0

我在運行代碼時收到此錯誤。主要問題是hplot沒有正確導入。從散景輸出的hplot無法正確導入以創建直方圖

File "MACD.py", line 10, in <module> 
    from bokeh.plotting import figure, show, output_file, hplot 
    ImportError: cannot import name hplot 

這裏是我的代碼:

macds = macd, macdsignal, macdhist = MACD(hloc, fastperiod=12, slowperiod=26, signalperiod=9) 
macdhist_f=[] 
iter=0 
for x in np.nditer(macdhist): 
    iter+=1 
    macdhist_f.append([iter,float(x)]) 
    print(type(x)) 
print macdhist_f 

macdhist_df = pd.DataFrame(macdhist_f) 

defaults.width = 450 
defaults.height = 350 

hist = Histogram(macdhist_df, values='macd hist', bins=50, 
       title="MACD Histogram") 
show(hplot(hist)) 
coin = "DASH_" 
output_file(coin + "html", title="macd") 
+0

看起來這是你的第一個問題!有幾件事 - >從你的Print語句看,你使用的是Python 2.x?通常很好澄清,雖然在這種情況下可能無關緊要。另外,您的具體問題不清楚您的頭銜。它看起來像你正在得到一個導入錯誤,這是你想解決的問題? – selllikesybok

回答