本文整理汇总了Python中bokeh.models.HoverTool.line_policy方法的典型用法代码示例。如果您正苦于以下问题:Python HoverTool.line_policy方法的具体用法?Python HoverTool.line_policy怎么用?Python HoverTool.line_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.HoverTool
的用法示例。
在下文中一共展示了HoverTool.line_policy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_points
# 需要导入模块: from bokeh.models import HoverTool [as 别名]
# 或者: from bokeh.models.HoverTool import line_policy [as 别名]
def show_points(pointsList, w=400, h=400):
# Ensure it's a list going in
if type(pointsList) is not list:
pointsList = [pointsList]
# Create the hover tool
hover = HoverTool(tooltips=[("x", "@x"),
("y", "@y")])
hover.line_policy = "nearest"
# Make the figure
fig = figure(plot_width=w, plot_height=h)
fig.add_tools(hover)
colors = ['red', 'orange', 'yellow', 'green',
'blue', 'purple', 'indigo', 'violet']
# Plot all the points
for i, points in enumerate(pointsList):
# Grab the color
color = colors[i % len(colors)]
# Plot the vertices
fig.x(x=points[:, 0],
y=points[:, 1],
size=6, line_width=2, line_color=color)
# Plot the lines
x, y = [np.hstack([points[:, z], points[0, z]]) for z in [0, 1]]
fig.line(x=x,
y=y,
line_width=2,
line_color=color)
# Plot the point index next to the point
fig.text(x=points[:, 0],
y=points[:, 1],
text=range(points.shape[0]))
# Show the plot
show(fig)