初学Bokeh:绘制条形图【7】跬步
Step1:引用figure、show函数
from bokeh.plotting import figure, show
Step2:定义绘图数据
# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]
Step3:创建绘图对象
# create a new plot with a title and axis labels
p = figure(title="Multiple glyphs example", x_axis_label="x", y_axis_label="y")
Step4:绘制折线图、条形图、圆形图
# add multiple renderers
# 绘制折线图
p.line(x, y1, legend_label="Temp.", line_color="blue", line_width=2)
# 绘制条形图,位置(x,y2);图例:Rate;条形的宽度:0.5;条形底部对应的数值:0;条形填充颜色:red
p.vbar(x=x, top=y2, legend_label="Rate", width=0.5, bottom=0, color="red")
# 绘制圆形
p.circle(x, y3, legend_label="Objects", line_color="yellow", size=12)
Step5:显示绘图对象
# show the results
show(p)
PS:由于绘图的时候是按照折线图、条形图、圆形图的次序绘制,因此条形图会遮挡住折线图,圆形图会遮挡住折线图和条形图。
标签:跬步,show,label,Bokeh,折线图,line,绘制,条形图 From: https://www.cnblogs.com/ohfaint/p/17772832.html