gpt4 book ai didi

python - 仅将鼠标悬停在带有 Bokeh 的选定行上

转载 作者:太空宇宙 更新时间:2023-11-04 00:11:10 26 4
gpt4 key购买 nike

我正在尝试选择我的悬停显示在 vline 模式下的行。

这是示例(取自 this SO 问题):

days = ['2018/1/1', '2018/1/2', '2018/1/3', '2018/1/4', '2018/1/5']
data_a = [10, 34, 23, 14, 58]
data_b = [20, 13, 45, 98, 65]
data_c = [20, 23, 43, 76, 57]
df_plot = pd.DataFrame({'A': data_a, 'B': data_b, 'C': data_c}, index=days)
df_plot['dates'] = pd.to_datetime(df_plot.index, format='%Y/%m/%d')
source = ColumnDataSource(df_plot)
p = figure(x_axis_type="datetime")
p.line('dates', 'A', source=source, color='red')
p.line('dates', 'B', source=source, color='blue')
p.line('dates', 'C', source=source, color='green')
p.add_tools(HoverTool(tooltips=[("A", "@A"), ("B", "@B"), ("C", "@C")],mode = "vline"))
show(p)

enter image description here

图像悬停出现在所有的行上,如果我只想悬停在红线上怎么办?

最佳答案

如果我理解得很好,您可以设置属性 renderers to the HoverTool

那么试试这个:

red_renderer_line = p.line('dates', 'A', source=source, color='red')
p.line('dates', 'B', source=source, color='blue')
p.line('dates', 'C', source=source, color='green')
p.add_tools(
HoverTool(
tooltips=[("A", "@A"), ("B", "@B"), ("C", "@C")],mode = "vline"
renderers=[red_renderer_line]
)
)

关于python - 仅将鼠标悬停在带有 Bokeh 的选定行上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52451654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com