【发布时间】:2018-02-02 00:00:41
【问题描述】:
我用jupyter notebook做了一个可视化的练习,然后我按照http://docs.bokeh.org/en/latest/docs/user_guide/tools.html#basic-tooltips上的代码进行操作
它有效,所以我尝试添加“格式化工具提示”,如下面的代码。
我只是添加了属性'formatters',但是发生了错误。
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
from bokeh.io import output_notebook, show
output_notebook()
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"),
],
formatters={
'desc' : 'printf', # use 'datetime' formatter for 'date' field
# use default 'numeral' formatter for other fields
}
)
p = figure(plot_width=400, plot_height=400, tools=[hover],
title="Mouse over the dots")
p.circle('x', 'y', size=20, source=source)
错误信息:
AttributeError: unexpected attribute 'formatters' to HoverTool, possible attributes are anchor, attachment, callback, js_callbacks, line_policy, mode, name, names, plot, point_policy, renderers, show_arrow, tags or tooltips
【问题讨论】:
-
我记得曾经遇到过类似的问题,问题是我正在关注最新的文档,但使用的是稍微旧一点的散景。首先尝试将散景包更新到最新版本。
-
好的,让我检查一下。谢谢
-
@IgnacioVergaraKausel 你是对的。我正在使用较旧的散景 0.12.4。更新软件包后,我解决了问题。非常感谢。