使用Bokeh Python没有显示烛台

时间:2018-08-07 08:12:06

标签: python python-3.x plot bokeh

我正在尝试运行以下代码来显示数据框的烛台图案。

from bokeh.plotting import figure, show, output_file

from math import pi

inc = df.close > df.open
dec = df.open > df.close
w = 12*60*60*1000 # half day in ms

TOOLS = "pan,wheel_zoom,box_zoom,reset,save"

p = figure(x_axis_type="datetime", tools=TOOLS, plot_width=1000, title = "MSFT Candlestick")
p.xaxis.major_label_orientation = pi/4
p.grid.grid_line_alpha=0.3

p.segment(df.index, high, df.index, low, color="black")
p.vbar(df.index[inc], w, df.open[inc], df.close[inc], fill_color="#D5E1DD", line_color="black")
p.vbar(df.index[dec], w, df.open[dec], df.close[dec], fill_color="#F2583E", line_color="black")

#output_file("candlestick.html", title="candlestick.py example")

show(p)  # open a browser

我在输出中什么都没有。请让我知道我错过了什么,所以我有所改善。

1 个答案:

答案 0 :(得分:1)

似乎您几乎在使用Bokeh examples中的代码。如果您运行该示例,它将打开而不会出现问题。 不幸的是,在您粘贴的代码中 df high low 没有定义,没有这些,我将无济于事。