Coordinate tooltips across multiple plots
See original GitHub issueFrom the mailing list:
I am using Bokeh 0.7.0 to generate a gridplot with hover. When I hover on one point within one of the subplots, text tips are displayed on all of the subplots (which is nice) but the location of the text tip is only accurate for the subplot where the mouse is hovering in (top right plot in the image attached). For all other subplots, the text tip appears in the same location relative to each subplot origin, which means that they are all pointing to an incorrect position (meaning the target point is not there).
More info:
I am attaching the code and the plot.
The inputs are: SNs: list of serial numbers columns: list of lists with data colnames: names for each of the columns of data colors: list of colors for all SNs outfile: output file name The data is 5000 SNs and 20 parameters. Thanks! Samir.
def bkGridPlot(SNs, columns, colnames, colors=[], outfile=def_file):
"""Try out a bokeh grid plot with hover
TODO:
4. Convert to app that can list outliers (within zoom)"""
## plot properties
import bokeh.plotting as bkp
from bokeh.models import HoverTool
bkp.output_file(outfile, title = outfile)
P = {
'TOOLS' : 'pan, wheel_zoom, select, reset, save, hover',
'canvasW' : 1200,
'canvasH' : 800,
'def_color' : 'olivedrab',
'fontsize' : '9',
'alpha' : 0.5,
'size' : 5
}
#TOOLS = 'pan, wheel_zoom, select, reset, save, hover'
#canvasW, canvasH = 1200, 800
# if no color input then choose my own
if len(colors)==0:
colors = P['def_color']
## determine grid size
Ncols = len(columns)
Nplots = (Ncols/2 if np.mod(Ncols, 2)==0 else (Ncols+1)/2)
# need to have an even number of columns so add 1 if needed
if 2*Nplots > Ncols:
columns.append(columns[0])
colnames.append(colnames[0])
Nx, Ny = findGridNxNy(Nplots)
## determine plot size
P['plotW'], P['plotH'] = int(P['canvasW']/Nx), int(P['canvasH']/Ny)
figs = []
print '%d plots of %d columns in %d by %d array' % (Nplots,len(columns),Nx,Ny)
## change column scale and label it properly to make plot more readable
columns10, colnames10 = niceScale(columns, colnames)
## create linking between columns using Bokeh ColumnDataSource
cds = cols2Bokeh(SNs, columns10, colnames)
counter=0
for i in range(Ny):
figrow = []
for j in range(Nx):
if counter<2*Nplots:
q = bkp.figure(
title = '',
x_axis_label = colnames10[counter],
y_axis_label = colnames10[counter+1],
tools = P['TOOLS'],
plot_width = P['plotW'],
plot_height = P['plotH']
)
q.circle(
colnames[counter], colnames[counter+1],
source = cds,
size = P['size'],
color = colors,
alpha = P['alpha']
)
bkp.xaxis().axis_label_text_font_size = P['fontsize']
bkp.yaxis().axis_label_text_font_size = P['fontsize']
hov = q.select(dict(type = HoverTool))
hov.tooltips = [
('ind', '$index'),
('SN', '@SN'),
('x', '@'+colnames[counter]),
('y', '@'+colnames[counter+1])
]
figrow.append(q)
counter += 2
figs.append(figrow)
p = bkp.gridplot(figs)
bkp.show(p)

Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:8 (7 by maintainers)

Top Related StackOverflow Question
bump…
I am in this exact situation - I have two plots, one showing water levels over time w multiline and another showing the well locations in “plan view”. All from one data source. Since a bunch of locations have wells at different depths, hovering over one plan view location will trigger hovering over multiple water level lines (this is fine). What I would like is the ability to trigger the hover on the water level plot to point out which hydrograph belongs to which well (so someone could easily say “ok the deepest well responded to pumping and the shallowest one didnt’” etc. I am able to add a callback to trigger the tooltips on both plots simultaneously, but as mentioned here, the tooltip shows up in the same location on the canvas and does not point to the actual location (should be pointing to the red dots).
This would be a suuuuper nice feature to have 😃
There hasn’t actually been a single outside user input on this in six years, not even a +1 or 👍 I’m going to close for lack of interest.