Hi, everyone! I’m a newbie using Bokeh. I had trouble using hover to show value and category together when I used vbar_stacks directly. Then I changed the dataframe(shown as below) and tried to loop vbar with CDSview for filtering category multiple times. But I got “Duplicate factor or subfactor error” in the output. Where did I do it wrong?
My code:
data = {‘prob’: prob,
‘prob_bottom’: prob_bottom,
‘prob_top’: prob_top,
‘preference_description’: preference_description,
‘preference_merchant’: preference_merchant}
source = ColumnDataSource(data=data)
hover = HoverTool(tooltips=[(‘description’,’@ preference_description’),
(‘prob’,’@prob’),
(‘merchant’,’@preference_merchant’)])
preference_description_unique = np.unique(preference_description).tolist()
p=figure(x_range= preference_description_unique,tools=[hover])
for i, merchant in enumerate(merchant_list):
view = CDSView(source=source, filters=[GroupFilter(column_name=‘preference_merchant’, group=merchant)])
p.vbar(x= ‘preference_description’, bottom = ‘prob_bottom’, top = ‘prob_top’, width=0.9, source = source, view = view, color = viridis(len(merchant_list))[i])
show(p)
···
My dataframe: Each ‘preference_description’ associates with 21 ‘preference_merchant’ and their probability values.
Many thanks!