答案 0 :(得分:1)
如果要标记特定点,一种方法是使用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
来支持换行符(但仅呈现文本,背景或边框)