我正在试验Bokeh,并遇到了令人沮丧的问题 . 它将填充颜色列为所涵盖的基本工具提示之一 .
http://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hover-tool
我试过了一个测试,颜色不会出现在hovertool上 . 它甚至没有给我“???”它通常会在你给它输入它不理解的时候,它完全忽略它 . 任何人都有一个线索,为什么它不会显示一个基本的工具提示?
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=[
("fill color", "$color[hex, swatch]:fill_color"),
("index", "$index"),
("(x,y)", "($x, $y)"),
("desc", "@desc"),
]
)
p = figure(plot_width=400, plot_height=400, tools=[hover],
title="Mouse over the dots")
p.circle('x', 'y', size=20, source=source, fill_color="black")
show(p)
1 回答
悬停工具提示只能检查列数据源中实际列的值 . 由于您已给出固定值,即
fill_color="black"
,因此没有要检查的列 . 此外,特殊悬停字段$color
与hex
只能理解十六进制颜色字符串 .以下是您修改的代码: