python - 使用 Bokeh Python 未显示烛台
问题描述
我正在尝试运行以下代码来显示我的数据框的烛台模式。
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
我在输出中没有得到任何东西。请让我知道我错过了什么,以便我改进。
解决方案
看来您使用的代码几乎与Bokeh 示例中的代码完全相同。如果您运行该示例,它将毫无问题地打开。不幸的是,在您粘贴的代码中df,high和low没有定义,如果没有这些,我无法为您提供太多帮助。
推荐阅读
- android - travis 无法确定依赖关系
- jupyter-notebook - Jupyter notebook Latex 无法让widebar工作
- java - Snowflake Java UDF 不能返回浮点数组?
- firebase - Firebase 重写规则不触发 Firebase 功能
- c# - 如何在循环接收的串行数据时保持当前的处理状态?
- facebook-graph-api - 无法从通过 Hashtag Search 恢复的 Instagram 帖子中恢复详细信息 - error_subcode 33
- javascript - 从除 splice 之外的 json 对象数组中删除对象的替代方法
- jquery - 根据第一个选择动态填充第二个下拉菜单
- sql - “[Microsoft][ODBC SQL Server Driver]无效参数号”错误
- javascript - 想知道为什么我的 XML URL Feed 数据没有在前端显示为 HTML。如果我在我的目录中托管静态 XML,它可以工作