☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Spans and HoverTool

Community Supporthover
cav71
cav71

Hi,

I have this plot:

from bokeh.plotting import ColumnDataSource, figure, show
from bokeh.io import output_notebook
from bokeh.models import HoverTool, PanTool, WheelZoomTool, ResetTool, Span

output_notebook()

p = figure(title='Example')

p.tools = [
    HoverTool(),
    PanTool(), 
    ResetTool(),
    WheelZoomTool(),
]
p.toolbar.active_scroll = p.tools[-1] 

country = 'Italy'
dset = datasets[country]
s0 = ColumnDataSource(dict(x=range(10), y=[ x**2 for x in range(10)]))
p.line('x', 'y', color='blue', source=s0)

span = Span(location=5, dimension='height', line_color='red', line_width=3)
p.add_layout(span)
show(p)

But it looks the HoverTool doesn’t show any information for the vertical span, is there any way to add it? Also how can I highlight the red vertical span on hever?

Thanks

⌁   Link to post
Bryan
Bryan

Is there any reason to allow panning on a chart like this? If not you can use p.line or p.segment or p.multi_line instead of a Span annotation. Or even if so, you can just make those lines bigger than the default ranges.

⌁   Link to post
_jm
_jm

If a Span is necessary or preferred for your application, the following workaround might be usable.

Create a glyph such as a circle in addition to your span and place it at the same x- coordinate. Set the glyph’s alpha(s) to 0.000 so that it is invisible. Attach a HoverTool to the glyph’s renderer, with the hit-test mode set to vline so that whenever the mouse is at the same x-coordinate (i.e. vertical line), the hovertool activates.

⌁   Link to post
Migwell
Migwell

HoverTool works only for glyphs, and Span is a layout. You can create a glyph instead of the span, although you can’t really have its dimension set to height like that.

Might I request that you support layouts with the HoverTool? This would be very helpful, considering there’s no existing glyph that produces infinite-length lines (except Ray, but that explicitly isn’t supported either!)

⌁   Link to post

End of archived discussion · Replies are disabled