question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coordinate tooltips across multiple plots

See original GitHub issue

From 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)

image

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
gmerritt123commented, Jan 20, 2021

bump…

  • Link on data. If there are shared data sources, it could make sense for the hover tool to react to the data selection. i.e. if you hover over the 37th point in one plot, a hover pops up over the 37th point on another plot (wherever it happens to be located). This is what the OP is asking for if I’m not mistaken. It’s completely reasonable, but there are also complications. For “pointlike” glyphs, it’s obvious where to position any additional hovers (at the x, y coords). But if the addition glyph is a patch… where do you position the additional hover tool? I guess we would need to add a lazy center attribute that can return a suitable coordinate for extended glyphs (for patches it would return the centroid, e.g)

Of course this only makes sense at all if there are shared data sources involved. We can’t assume in general that the 918th data point on one data source has anything at all to do with the 918th data point in some other data source (if there even is one)

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).

image

This would be a suuuuper nice feature to have 😃

0reactions
bryevdvcommented, Aug 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Synchronizing Tooltips over multiple plots bokeh
Synchronizing Tooltips over multiple plots bokeh ... I have created a grid plot using bokeh consisting of multiple vertically stacked line charts ......
Read more >
FAQ-972 Can I modify the tooltips that appear when I hover on ...
In 2D plots that support both types of tooltips, you can switch between the two by right-clicking on the tooltip and choosing from...
Read more >
25 Controlling tooltips
There are two main approaches to controlling the tooltip: hoverinfo and ... attribute controls what other plot attributes are shown into the tooltip...
Read more >
Configuring plot tools — Bokeh 2.4.3 Documentation
Inspectors are passive tools that annotate or report information about the plot based on the current cursor position. Multiple inspectors may be active...
Read more >
Tooltips with Python's Matplotlib | by Thiago Carvalho
Cursor XY coordinates ... The idea is to draw the chart with all the elements we'll use and then use the events to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found