我用jupyter筆記本做可視化的做法「意外屬性‘格式化’到HoverTool」,然後我也跟着上http://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#basic-tooltipsPython的背景虛化HoverTool格式化錯誤:
它的工作原理的代碼,所以我試圖添加「格式化工具提示」,如下面的代碼。
我只是添加了屬性'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
我記得有一個類似的問題一次,問題是,我是按照最新的文檔,但使用年齡稍大的背景虛化。先嚐試更新您的散景套餐到最新的套餐。 –
好的,讓我檢查一下。謝謝 – fishballLin
@IgnacioVergaraKausel你是對的。我正在使用較舊的散景0.12.4。更新軟件包後,我解決了這個問題。非常感謝你。 – fishballLin