如果要标记特定点,一种方法是使用Label
注释:
import numpy as np
from bokeh.plotting import figure, show
from bokeh.models import Label
x = np.linspace(0, 10, 1000)
y = np.sin(x)
p = figure()
p.line(x, y)
# define the distinguished point
x0, y0 = x[175], y[175]
# label the distinguished point
p.circle(x=x0, y=y0)
citation = Label(x=x0, y=y0,
text='x: %f y: %f' % (x0, y0),
x_offset=5, y_offset=5,
border_line_color='black',
background_fill_color='lightgray')
p.add_layout(citation)
show(p)
结果如下:
请注意,Label
尚不支持换行符。我需要你,你可以:
p.text
,它支持换行符(但只渲染文本,背景或边框)