我对散景条形图有问题。 这是我的代码:
from bkcharts import Bar
from bokeh.models import FactorRange
# Make Bokeh Push push output to Jupyter Notebook.
from bokeh.io import push_notebook, show, output_notebook
from bokeh.resources import INLINE
output_notebook(resources=INLINE)
from bokeh.models import HoverTool
data = {
'name' : [chan['name'] for chan in full_channels_info],
'members' : [chan['num_members'] for chan in full_channels_info]
}
hover = HoverTool(tooltips=[
("Channel", "@name"),
("Users", "@members"),
])
chart = Bar(data, values='members', label='name',
title="Channels population", plot_width=1000, xlabel="Channel", ylabel="Members",
legend=None, tools=[hover])
show(chart)
问题在于,当我将鼠标悬停在其中一个栏上时,工具提示看起来像这样:
答案 0 :(得分:2)
问题在于HoverTool()
,您应该引用@height
而不是@members
。
hover = HoverTool(tooltips=[
("Channel", "@name"),
("Users", "@height"),
])