初学Bokeh:绘制圆形【6】跬步

发布时间 2023-10-17 21:37:59作者: ohfaint

初学Bokeh:绘制圆形【6】跬步

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
# 绘制2条折线
 p.line(x, y1, legend_label="Temp.", line_color="blue", line_width=2) 
p.line(x, y2, legend_label="Rate", line_color="red", line_width=2) 
# 绘制圆形:圆心位置(x,y3);图例:Objects;颜色(圆边的颜色):yellow;尺寸:12像素
p.circle(x, y3, legend_label="Objects", line_color="yellow", size=12) 

Step5:显示绘图对象

# show the results 
show(p)

fig1