HoverTool 可以在直线上插值一个点吗?

Can HoverTool interpolate a point on a straight line?

提问人:justin 提问时间:11/4/2023 更新时间:11/4/2023 访问量:20

问:

当我使用两点 (0,0) 和 (10,10) 绘制一条线(使用方程 y = x)并使用 时,我希望 HoverTool 报告 y = x。然而,情况似乎并非如此(在下面的屏幕截图中,x = 6.443 和 y = 6.551)。如何让插值正常工作 (x = y)?line_policy = interp

bokehplot

from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure, output_notebook, show

output_notebook()

graph = figure(width=300, height=300, toolbar_location="right")

data = {"xs": [[0,10]], "ys": [[0,10]]}

ml = graph.multi_line(xs="xs", ys="ys", source=ColumnDataSource(data))

hover_tool_ml = HoverTool(
    line_policy="interp",
    renderers=[ml],
    tooltips=[
        ("y", "$y"),
        ("x", "$x"),
    ]
)
graph.add_tools(hover_tool_ml)
show(graph)
散景

评论


答: 暂无答案