Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinate tooltips across multiple plots #1547

Closed
damianavila opened this issue Dec 13, 2014 · 8 comments
Closed

Coordinate tooltips across multiple plots #1547

damianavila opened this issue Dec 13, 2014 · 8 comments

Comments

@damianavila
Copy link
Contributor

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

@damianavila
Copy link
Contributor Author

@bryevdv ping, are we actually support the "relocalization" of the hover in a gridplot setup? I don't think so, but maybe I am missing something...

@bryevdv
Copy link
Member

bryevdv commented Dec 13, 2014

Well, it's complicated. There are lots of potential behaviors, and most of them are reasonable in some scenarios. For instance,

  • No linkage, if none is desired. Hover inspections on subplots are completely independent.
  • 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)

  • Link on geometry. You might want the geometry of the inspection on one plot to trigger a completely new inspection (using that same geometry) on another plot. So if the cursor is at (10.5, 7) on one plot, then the additional plots do a hit test at (10.5, 7) and if there are glyphs that have any hovers a that point, then a hover gets drawn there.

Although always technical workable, only useful if the visible ranges of the plots are close or overlap.

All of this also intersects with the fact that we don't handle multiple "hits" very well currently, either. We will need to have something that can manage hover tooltips at a higher level and possibly across subplots to solve all these problems.

@bryevdv
Copy link
Member

bryevdv commented Dec 13, 2014

@damianavila as an aside I think all tracker issues should just contain a link to the OP, and a brief summary but not try to re-quote everything. Something like:

references: https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/EI6STAzLIcY

(I assume that is the OP in this case)

@damianavila damianavila added this to the long-term milestone Dec 19, 2014
@damianavila
Copy link
Contributor Author

@damianavila as an aside I think all tracker issues should just contain a link to the OP, and a brief summary but not try to re-quote everything. Something like:

Yep... after posting it I was thinking in the same... there is no sense in duplication, with a reference is enough (except for code that makes sense to translate here if is a big chunk).

@damianavila
Copy link
Contributor Author

No linkage, if none is desired. Hover inspections on subplots are completely independent.

Which is possible right now...

This is what the OP is asking for if I'm not mistaken.

Yep

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)

Yes, a center of gravity point :wink"

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)

That's true too...

Link on geometry. You might want the geometry of the inspection on one plot to trigger a completely new inspection (using that same geometry) on another plot. So if the cursor is at (10.5, 7) on one plot, then the additional plots do a hit test at (10.5, 7) and if there are glyphs that have any hovers a that point, then a hover gets drawn there.
Although always technical workable, only useful if the visible ranges of the plots are close or overlap.

This would be nice... I though in the same behaviour when I read the OP at first time...

All of this also intersects with the fact that we don't handle multiple "hits" very well currently, either. We will need to have something that can manage hover tooltips at a higher level and possibly across subplots to solve all these problems.

Yes... I agree...

@fpliger
Copy link
Contributor

fpliger commented Dec 19, 2014

All of this also intersects with the fact that we don't handle multiple "hits" very well currently, either. We will need to have something that can manage hover tooltips at a higher level and possibly across subplots to solve all these problems.

just for reference, #1486 was opened to handle the multiple hits.

@bryevdv bryevdv changed the title Bokeh gridplot with hover shows texttip in incorrect locations Coordinate tooltips across multiple plots Apr 10, 2018
@bryevdv
Copy link
Member

bryevdv commented 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.

@bryevdv bryevdv closed this as completed Aug 25, 2020
@bryevdv bryevdv removed this from the long-term milestone Aug 25, 2020
@gmerritt123
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants