条形图工具提示上缺少值

时间:2017-07-28 18:20:35

标签: python-3.x jupyter-notebook bokeh

我对散景条形图有问题。 这是我的代码:

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)

问题在于,当我将鼠标悬停在其中一个栏上时,工具提示看起来像这样:

enter image description here

1 个答案:

答案 0 :(得分:2)

问题在于HoverTool(),您应该引用@height而不是@members

hover = HoverTool(tooltips=[
    ("Channel", "@name"),
    ("Users", "@height"),
])