初学Bokeh:自定义标题【12】跬步
大多数绘图都包含标题(headline)。可以通过向 figure() 函数传递标题参数来为图像添加标题:
p = figure(title="Headline example")
标题文本有多种样式,示例如下:
from bokeh.plotting import figure, show
# prepare some data
# 定义绘图数据
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
# create new plot
# 创建绘图对象
p = figure(title="Headline example")
# add line renderer with a legend
# 添加一个line对象,对应图例(legend):Temp.,线宽:2
p.line(x, y, legend_label="Temp.", line_width=2)
# change headline location to the left
# 设置标题的位置:left
p.title_location = "left"
# change headline text
# 设置标题内容
p.title.text = "Changing headline text example"
# style the headline
# 设置标题样式
p.title.text_font_size = "25px" # 字体大小
p.title.align = "right" # 对齐方式
p.title.background_fill_color = "darkgrey" # 背景填充色
p.title.text_color = "white" # 文字颜色
# show the results
show(p)
标签:12,figure,自定义,title,headline,text,标题,跬步,line
From: https://www.cnblogs.com/ohfaint/p/17773192.html