Search code examples
pythonplottooltipbokeh

Bokeh Ray glyphs not displaying tooltips


I cannot get Ray glyphs in Bokeh (v2.2.3 with Python 3.8.6) to work with the HoverTool. The tooltips just won't show.

import numpy as np

from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource, HoverTool, Range1d
from bokeh.plotting import figure

output_notebook()


N = 9
x0 = np.zeros(N)
y0 = np.ones(N)
x = np.linspace(-2, 2, N)
y = x**2
z = x + 1j * y

source = ColumnDataSource(dict(x=x0, y=y0, length=np.absolute(z), angle=np.angle(z)))

fig = figure(title='', plot_width=300, plot_height=300)
fig.ray(x='x', y='y', length='length', angle='angle', source=source, line_width=2)
tooltips = [('length', '@length'), ('angle', '@angle')]
fig.add_tools(HoverTool(tooltips=tooltips))
fig.x_range = Range1d(-2, 2)
fig.y_range = Range1d(0, 4)

show(fig)

output


Solution

  • Ray glyphs do not currently support any hit-testing (i.e. they cannot be used with hover tools).

    https://github.com/bokeh/bokeh/wiki/Glyph-Hit-Testing-Census

    Your best alternative is segment or multi_line.