我们先看一个例子:
from bokeh.plotting import figure, output_file, show
output_file("patch.html")
p = figure(plot_width=400, plot_height=400)
# add a patch renderer with an alpha an line width
p.patch([1, 2, 3, 4, 5], [6, 7, 8, 7, 3], alpha=0.5, line_width=2)
show(p)
从bokeh.plotting模块中引入figure、output_file、show。之前介绍过,figure实际上是一个函数,返回值为Figure类。output_file和show并没有在bokeh.plotting在定义,而是继承于父类——bokeh.io。
bokeh.io
bokeh.io类中包含了如下几种类:
bokeh.io.output
bokeh.io.output中有output_file()方法,这个就是"from bokeh.plotting import output_file"中的output_file。
具体使用方法如下: