New in Bokeh, I'm trying to build a html page with boxgroupcheck.
Below is df
UC_Month dep_delayed_15min_count dep_delayed_15min_sum dep_delayed_15min_Percent UC
AA-01 797 153 0.192 AA
AA-02 708 128 0.181 AA
AA-03 799 157 0.196 AA
I create a plot with bokeh using the following code
# Call once to configure Bokeh to display plots inline in the notebook.
output_notebook()
def plot_col(data, col, long, larg):
# Output file
output_file("bar_stacked_split.html")
# Define Labels
group = data[col].unique()
target = ['Flight on Time', 'Flight Delayed']
colors = ['blue', 'red']
# Define Values
val = {'Group': group,
'Flight on Time' : 1 - data['dep_delayed_15min_Percent'],
'Flight Delayed' : data['dep_delayed_15min_Percent']}
# Define plots
p1 = figure(plot_width = long, plot_height = larg, y_range = group,
tools=["box_zoom", "wheel_zoom", "lasso_select", "reset", "save"], tooltips= "$name @Group: @$name")
p1.hbar_stack(target, y= 'Group', height=0.9, color=colors, source= val, legend_label= target)
val2 = {'Group': group,
'Flight on Time' : data['dep_delayed_15min_count'] - data['dep_delayed_15min_sum'],
'Flight Delayed' : data['dep_delayed_15min_sum'] }
p2 = figure(plot_width= long, plot_height= larg, y_range= group,
tools=["box_zoom", "wheel_zoom", "lasso_select", "reset", "save"], tooltips= "$name @Group: @$name")
p2.hbar_stack(target, y='Group', height=0.9, color=colors, source= val2, legend_label= target)
return show(row(p1, p2))
Then I apply the plot function
plot_col(train_ucmonth, 'UC_Month', 750, 5550)
Which gives me this output
So, what I'm trying to do after that is to create a checkbox with train_ucmonth.UC.unique() and update the html output
I have found many ressources on internet regarding the checkboxgroup such as this one
However, my problem is that I already have a 'target' that I have 'flight delayed' and 'flight not delayed'.
Thus, my question is how can I add a filter box with column 'UC' and keeping my target like in my plot.
Edit
How can I add in the above plot a checkbox with the following values?
- WN
- AA
- UA
- OO
- OA
By selecting only one unique carrier, the plot should be updated.
Thanks for anyone helping!