1

Is the hover tool for patch different than other glyphs? The plot can see the index for circle but not for patch.

output_file("patch.html")

    TOOLTIPS = [
        ("index", "$index"),
    ]
    p = figure(plot_width=400, plot_height=400, tooltips=TOOLTIPS, tools='hover,help')

    # add a patch renderer with an alpha an line width
    p.patch([1, 2, 3, 4, 5], [6, 7, 8, 7, 3], alpha=0.5, line_width=2)
    p.circle([2], [4],size=20, line_width=2)

    show(p)

enter image description here enter image description here

1 Answers1

1

As of Bokeh 1.0.2, hit testing has not been implemented for Patch, i.e. it is invisible as far as the Hover tool is concerned. You could use the vectorized patches glyph method instead:

p.patches([[1, 2, 3, 4, 5]], [[6, 7, 8, 7, 3]], alpha=0.5, line_width=2)

However, this will always only return 0 as the value of $index since there is only just the one patch (whose index is 0). If you are looking to get "index" values for the vertices of the patch, you will need to do something like plot invisible circles at the same locations as the vertices, that are only there for hit-testing purposes (to drive the hover tool)

bigreddot
  • 33,642
  • 5
  • 69
  • 122