1

我在运行我的代码时收到此错误。主要问题是 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")
4

1 回答 1

8

hplot已被弃用很长时间(您应该已经看到关于此的运行时警告?)并且它最近被完全删除。您想要的类似功能是bokeh.layouts.row,例如

from bokeh.layouts import row

show(row(plot1, plot2))

有关一般布局的更多信息:

https://docs.bokeh.org/en/latest/docs/user_guide/layout.html

于 2017-06-13T18:59:47.910 回答