Bokeh hover tooltip not displaying all data - Ipython notebook

后端 未结 2 2088
陌清茗
陌清茗 2020-12-18 09:07

I am experimenting with Bokeh and mixing pieces of code. I created the graph below from a Pandas DataFrame, which displays the graph correctly with all the tool elements I w

相关标签:
2条回答
  • 2020-12-18 09:40

    Try using ColumnDataSource.

    Hover tool needs to have access to the data source so that it can display info. @x, @y are the x-y values in data unit. (@ prefix is special, can only followed by a limited set of variable, @y2 is not one of them)., Normally I would use $+ column_name to display the value of my interest, such as $weight. See here for more info.

    Besides, I am surprised that the hover would appear at all. As I thought hoverTool doesn't work with line glyph, as noted here

    Try the following : (I haven't tested, might have typos).

    df = yearly_DF.reset_index() # move index to column.
    source = ColumnDataSource(ColumnDataSource.from_df(df)
    
    hover.tooltips = OrderedDict([('x', '@x'),('y', '@y'), ('year', '$index'), ('weight','$weight'), ('muscle_weight','$muscle_weight'), ('body_fat','$bodyfat_p')])
    
    p.line(x='index', y='weight', source=source, legend="Weight")
    p.line(x='index', y='muscle_weight', source=source, legend="Muscle Mass", line_color="red")
    
    0 讨论(0)
  • 2020-12-18 09:56

    Are you using Firefox? This was a reported issue with some older versions of FF:

    https://github.com/bokeh/bokeh/issues/1981

    https://github.com/bokeh/bokeh/issues/2122

    Upgrading FF resolved the issue.

    0 讨论(0)
提交回复
热议问题