来自散景的 hplot 无法正确导入以创建直方图
hplot from bokeh isn't importing correctly to create a histogram
我在 运行 我的代码中收到此错误。主要问题是 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")
hplot
已被弃用很长时间(您应该已经看到有关此的运行时警告?)并且最近被完全删除。您想要的类似函数是 bokeh.layouts.row
,例如
from bokeh.layouts import row
show(row(plot1, plot2))
有关一般布局的更多信息:
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html
我在 运行 我的代码中收到此错误。主要问题是 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")
hplot
已被弃用很长时间(您应该已经看到有关此的运行时警告?)并且最近被完全删除。您想要的类似函数是 bokeh.layouts.row
,例如
from bokeh.layouts import row
show(row(plot1, plot2))
有关一般布局的更多信息:
https://docs.bokeh.org/en/latest/docs/user_guide/layout.html