☰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

HoverTool for Stacked vBar on Bokeh

Community Support
VT_Sol
VT_Sol

hi,

I am not very sure how to make the hovertool to work on a stacked vbar. my guess is not input the right data to the hovertool? the code is below

from bokeh.core.properties import value

from bokeh.plotting import figure, show

from bokeh.models import ColumnDataSource

from bokeh.models import HoverTool

fruits = [‘0’,‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘10’,‘11’,‘12’,‘13’,‘14’,‘15’,‘16’,‘17’,‘18’,‘19’,‘20’,‘21’,‘22’,‘23’]

colorType = [“blueNums”, “greenNums”]

colors = [“blue”, “green”]

data = {‘fruits’ : fruits,

‘blueNums’ : [2, 1, 4, 3, 2, 4, 1, 4, 3, 2, 4,5, 3, 4, 2, 4, 6, 1, 4, 3, 2, 4,2,2],

‘greenNums’ : [5, 3, 4, 2, 4, 6, 1, 4, 3, 2, 4,5, 3, 4, 2, 4, 6, 1, 4, 3, 2, 4,2,2],

}

source = ColumnDataSource(data=data)

p = figure(x_range=fruits, plot_width=1000, title=“Fruit Counts by Year”,

toolbar_location=“right”, tools=“reset,pan”)

r1 = p.vbar_stack(colorType, x=‘fruits’, width=0.9, color=colors, source=source,

legend=[value(x) for x in colorType])

hover = HoverTool(renderers=[r1])

hover.tooltips=[ (“Blue_hover”, “$blueNums”),(“Green_hover”, “$sellNums”) ]

p.add_tools(hover)

show(p)

Thanks.

⌁   Link to post

End of archived discussion · Replies are disabled