Created
January 20, 2017 03:22
-
-
Save npyoung/05fe971dff89353b4b627b0fe0f64917 to your computer and use it in GitHub Desktop.
Bokeh server app for adjusting a data range with a slider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bokeh.layouts import widgetbox, column | |
from bokeh.models.widgets import RangeSlider | |
from bokeh.models.ranges import Range | |
from bokeh.plotting import figure, curdoc | |
range_slider = RangeSlider(start=0, end=10, range=(1,9), step=.1, title="Stuff") | |
p = figure(x_range=range_slider.range) | |
p.line(x=range(10), y=[x**2 for x in range(10)]) | |
def update_range(attr, new, old): | |
p.x_range.start = new[0] | |
p.x_range.end = new[1] | |
range_slider.on_change('range', update_range) | |
curdoc().add_root(column(p, widgetbox(range_slider))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment