使用悬停工具时启用平移/缩放

问题描述 投票:0回答:1

使用此示例-http://docs.bokeh.org/en/latest/docs/user_guide/tools.html#hover-tool,我一直在尝试启用悬停工具时启用平移/缩放。但是,我似乎无法让两者一起工作。

它们是互斥的工具吗?

bokeh
1个回答
1
投票

我在错误的位置指定了工具。如果有人尝试这样做,这是一个有效的示例-

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

output_file("toolbar.html")

source = ColumnDataSource(
    data=dict(
        x=[1,2,3,4,5],
        y=[2,5,8,2,7],
        desc=['A', 'b', 'C', 'd', 'E'],
    )
)

hover = HoverTool(
    tooltips = [
        ("index", "$index"),
        ("(x,y)", "($x, $y)"),
        ("desc", "@desc"),
    ]
)

p = figure(plot_width=400, plot_height=400, tools=[hover, 'pan', 'wheel_zoom'],
           title="Mouse over the dots")

p.circle('x', 'y', size=20, source=source)

show(p)
© www.soinside.com 2019 - 2024. All rights reserved.