2
votes

I have a pandas DataFrame of about 30 columns, each which has data for the same dates (e.g. the columns of the DataFrame are the sensors, the rows of the DataFrame are the readings of the sensors on those dates). I want to be able to hover over the data points and have a tooltip of that sensor reading. I can do this by creating one HoverTool for each sensor name and naming each glyph. The only issue with this is that the 30 different HoverTools appear on the right side of the plot which is ugly. I thought HoverTool.always_active would fix this, but it appears that this functionality is not implemented.

Is there a way to hide the HoverTool icon in bokeh? If not, is there a better way to implement HoverTool on a DataFrame? I could reshape the data to be a [n,3] array, but I would rather not.

The columns are ["Sensor A, X", "Sensor A, Y", "Sensor B, X", "Sensor B, Y",...] so I have one HoverTool for glyphs with name "Sensor A" and one for glyphs with name "Sensor B", etc.

With a long list of tool tips for one HoverTool: enter image description here

With a lot of HoverTools:

enter image description here

I can get around the list of HoverTools by hiding the tool bar, but it isn't a very clean solution.

2

2 Answers

1
votes

Asuming the your data are loaded into Bokeh using

source = ColumnDataSource(df)

then you could try something like

p.select_one(HoverTool).tooltips = [
    (value, value_data),
    ('A_X', '@A_x'),
    ('A_Y', '@A_Y')
]

Have a look at

http://docs.bokeh.org/en/latest/docs/gallery/unemployment.html

-1
votes

I ended up using the melt function in pandas to covert the [26,28] pandas dataframe into a [2,364] dataframe so that I only needed to use one hovertool.