Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Created March 19, 2018 00:09
Show Gist options
  • Save WillKoehrsen/dcd0341852f9d821e1a8d2828aafcc86 to your computer and use it in GitHub Desktop.
Save WillKoehrsen/dcd0341852f9d821e1a8d2828aafcc86 to your computer and use it in GitHub Desktop.
# Slider to select the binwidth, value is selected number
binwidth_select = Slider(start = 1, end = 30,
step = 1, value = 5,
title = 'Delay Width (min)')
# Update the plot when the value is changed
binwidth_select.on_change('value', update)
# RangeSlider to change the maximum and minimum values on histogram
range_select = RangeSlider(start = -60, end = 180, value = (-60, 120),
step = 5, title = 'Delay Range (min)')
# Update the plot when the value is changed
range_select.on_change('value', update)
# Update function that accounts for all 3 controls
def update(attr, old, new):
# Find the selected carriers
carriers_to_plot = [carrier_selection.labels[i] for i in carrier_selection.active]
# Change binwidth to selected value
bin_width = binwidth_select.value
# Value for the range slider is a tuple (start, end)
range_start = range_select.value[0]
range_end = range_select.value[1]
# Create new ColumnDataSource
new_src = make_dataset(carriers_to_plot,
range_start = range_start,
range_end = range_end,
bin_width = bin_width)
# Update the data on the plot
src.data.update(new_src.data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment