當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Slider方法代碼示例

本文整理匯總了Python中bokeh.models.Slider方法的典型用法代碼示例。如果您正苦於以下問題:Python models.Slider方法的具體用法?Python models.Slider怎麽用?Python models.Slider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bokeh.models的用法示例。


在下文中一共展示了models.Slider方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: modify_doc

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25), y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    # doc.theme = Theme(filename="theme.yaml") 
開發者ID:pythonstock,項目名稱:stock,代碼行數:23,代碼來源:tornado_bokeh_embed.py

示例2: test_discrete_slider

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def test_discrete_slider(document, comm):
    discrete_slider = DiscreteSlider(name='DiscreteSlider', value=1,
                                     options=[0.1, 1, 10, 100])

    box = discrete_slider.get_root(document, comm=comm)

    label = box.children[0]
    widget = box.children[1]
    assert isinstance(label, BkDiv)
    assert isinstance(widget, BkSlider)
    assert widget.value == 1
    assert widget.start == 0
    assert widget.end == 3
    assert widget.step == 1
    assert label.text == 'DiscreteSlider: <b>1</b>'

    widget.value = 2
    discrete_slider._slider._process_events({'value': 2})
    assert discrete_slider.value == 10

    discrete_slider.value = 100
    assert widget.value == 3 
開發者ID:holoviz,項目名稱:panel,代碼行數:24,代碼來源:test_slider.py

示例3: test_discrete_date_slider

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def test_discrete_date_slider(document, comm):
    dates = OrderedDict([('2016-01-0%d' % i, datetime(2016, 1, i)) for i in range(1, 4)])
    discrete_slider = DiscreteSlider(name='DiscreteSlider', value=dates['2016-01-02'],
                                     options=dates)

    box = discrete_slider.get_root(document, comm=comm)

    assert isinstance(box, BkColumn)

    label = box.children[0]
    widget = box.children[1]
    assert isinstance(label, BkDiv)
    assert isinstance(widget, BkSlider)
    assert widget.value == 1
    assert widget.start == 0
    assert widget.end == 2
    assert widget.step == 1
    assert label.text == 'DiscreteSlider: <b>2016-01-02</b>'

    widget.value = 2
    discrete_slider._slider._process_events({'value': 2})
    assert discrete_slider.value == dates['2016-01-03']

    discrete_slider.value = dates['2016-01-01']
    assert widget.value == 0 
開發者ID:holoviz,項目名稱:panel,代碼行數:27,代碼來源:test_slider.py

示例4: test_discrete_slider_options_dict

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def test_discrete_slider_options_dict(document, comm):
    options = OrderedDict([('0.1', 0.1), ('1', 1), ('10', 10), ('100', 100)])
    discrete_slider = DiscreteSlider(name='DiscreteSlider', value=1,
                                     options=options)

    box = discrete_slider.get_root(document, comm=comm)

    label = box.children[0]
    widget = box.children[1]
    assert isinstance(label, BkDiv)
    assert isinstance(widget, BkSlider)
    assert widget.value == 1
    assert widget.start == 0
    assert widget.end == 3
    assert widget.step == 1
    assert label.text == 'DiscreteSlider: <b>1</b>'

    widget.value = 2
    discrete_slider._slider._process_events({'value': 2})
    assert discrete_slider.value == 10

    discrete_slider.value = 100
    assert widget.value == 3 
開發者ID:holoviz,項目名稱:panel,代碼行數:25,代碼來源:test_slider.py

示例5: modify_doc

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25), y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    doc.theme = Theme(filename="theme.yaml") 
開發者ID:andrewcooke,項目名稱:choochoo,代碼行數:23,代碼來源:test_bokeh_server.py

示例6: home_handler

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def home_handler(doc):
    data = {'x': [0, 1, 2, 3, 4, 5], 'y': [0, 10, 20, 30, 40, 50]}
    source = ColumnDataSource(data=data)

    plot = figure(x_axis_type="linear", y_range=(0, 50), title="Test App Bokeh + Channels Plot", height=250)
    plot.line(x="x", y="y", source=source)

    def callback(attr: str, old: Any, new: Any) -> None:
        if new == 1:
            data['y'] = [0, 10, 20, 30, 40, 50]
        else:
            data['y'] = [i * new for i in [0, 10, 20, 30, 40, 50]]
        source.data = dict(ColumnDataSource(data=data).data)
        plot.y_range.end = max(data['y'])

    slider = Slider(start=1, end=5, value=1, step=1, title="Test App Bokeh + Channels Controller")
    slider.on_change("value", callback)

    doc.add_root(column(slider, plot)) 
開發者ID:tethysplatform,項目名稱:tethys,代碼行數:21,代碼來源:controllers.py

示例7: prepare_bls_help_source

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def prepare_bls_help_source(bls_source, slider_value):
    data = dict(period=[bls_source.data['period'][int(slider_value*0.95)]],
                power=[(np.max(bls_source.data['power']) - np.min(bls_source.data['power'])) * 0.98 + np.min(bls_source.data['power'])],
                helpme=['?'],
                help=["""
                             <div style="width: 375px;">
                                 <div style="height: 190px;">
                                 </div>
                                 <div>
                                     <span style="font-size: 12px; font-weight: bold;">Box Least Squares Periodogram</span>
                                 </div>
                                 <div>
                                     <span style="font-size: 11px;"">This panel shows the BLS periodogram for
                                      the light curve shown in the lower panel.
                                     The current selected period is highlighted by the red line.
                                     The selected period is the peak period within the range.
                                     The Folded Light Curve panel [right] will update when a new period
                                     is selected in the BLS Panel. You can select a new period either by
                                     using the Box Zoom tool to select a smaller range, or by clicking on the peak you want to select. </span>
                                     <br></br>
                                     <span style="font-size: 11px;"">The panel is set at the resolution
                                     given by the Resolution Slider [bottom]. This value is the number
                                     of points in the BLS Periodogram panel.
                                     Increasing the resolution will make the BLS Periodogram more accurate,
                                     but slower to render. To increase the resolution for a given peak,
                                     simply zoom in with the Box Zoom Tool.</span>

                                 </div>
                             </div>
                         """])
    return ColumnDataSource(data=data) 
開發者ID:KeplerGO,項目名稱:lightkurve,代碼行數:33,代碼來源:interact_bls.py

示例8: test_bkwidget_hvplot_links

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def test_bkwidget_hvplot_links(document, comm):
    from bokeh.models import Slider
    bokeh_widget = Slider(value=5, start=1, end=10, step=1e-1)
    points1 = hv.Points([1, 2, 3])

    Link(bokeh_widget, points1, properties={'value': 'glyph.size'})

    row = Row(points1, bokeh_widget)
    model = row.get_root(document, comm=comm)
    hv_views = row.select(HoloViews)

    assert len(hv_views) == 1
    slider = bokeh_widget
    scatter = hv_views[0]._plots[model.ref['id']][0].handles['glyph']

    link_customjs = slider.js_property_callbacks['change:value'][-1]
    assert link_customjs.args['source'] is slider
    assert link_customjs.args['target'] is scatter

    code = """
    var value = source['value'];
    value = value;
    value = value;
    try {
      var property = target.properties['size'];
      if (property !== undefined) { property.validate(value); }
    } catch(err) {
      console.log('WARNING: Could not set size on target, raised error: ' + err);
      return;
    }
    try {
      target['size'] = value;
    } catch(err) {
      console.log(err)
    }
    """
    assert link_customjs.code == code 
開發者ID:holoviz,項目名稱:panel,代碼行數:39,代碼來源:test_links.py

示例9: test_bkwidget_bkplot_links

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def test_bkwidget_bkplot_links(document, comm):
    from bokeh.models import Slider
    bokeh_widget = Slider(value=5, start=1, end=10, step=1e-1)
    bokeh_fig = figure()
    scatter = bokeh_fig.scatter([1, 2, 3], [1, 2, 3])

    Link(bokeh_widget, scatter, properties={'value': 'glyph.size'})

    row = Row(bokeh_fig, bokeh_widget)
    row.get_root(document, comm=comm)

    slider = bokeh_widget

    link_customjs = slider.js_property_callbacks['change:value'][-1]
    assert link_customjs.args['source'] is slider
    assert link_customjs.args['target'] is scatter.glyph

    code = """
    var value = source['value'];
    value = value;
    value = value;
    try {
      var property = target.properties['size'];
      if (property !== undefined) { property.validate(value); }
    } catch(err) {
      console.log('WARNING: Could not set size on target, raised error: ' + err);
      return;
    }
    try {
      target['size'] = value;
    } catch(err) {
      console.log(err)
    }
    """
    assert link_customjs.code == code 
開發者ID:holoviz,項目名稱:panel,代碼行數:37,代碼來源:test_links.py

示例10: next_image

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def next_image(files, action):
    global file_textbox, button, button_next, button_prev, index
    print("next clicked")
    file_textbox.value = "Processing..."
    renderer = hv.renderer('bokeh')
    if action == 'next':
        index=(index + 1) % len(files)
    else:
        index=(index - 1) % len(files)
    #print("it ", iterator)
    print("index before check",index)
    index = check_errors(files, index, action)
    print("index after check", index)
    print("len", len(files))

    file_name = files[index]
    rgb_images, frame_indices, gripper_status, action_status, gripper_action_label, gripper_action_goal_idx = process_image(file_name)
    print("image loaded")
    print("action goal idx", gripper_action_goal_idx)
    height = int(rgb_images[0].shape[0])
    width = int(rgb_images[0].shape[1])
    start = 0
    end = len(rgb_images) - 1
    print(' End Index of RGB images: ' + str(end))

    def slider_update(attrname, old, new):
        plot.update(slider.value)

    slider = Slider(start=start, end=end, value=0, step=1, title="Frame", width=width)
    slider.on_change('value', slider_update)

    holomap = generate_holo_map(rgb_images, height, width)
    print("generated holomap")
    plot = renderer.get_plot(holomap)
    print("plot rendered")
    gripper_plot, action_plot, gripper_action_plot = load_data_plot(renderer, frame_indices, gripper_status, action_status, gripper_action_label, height, width)
    print("plot loaded..")
    plot_list = [[plot.state], [gripper_plot.state], [action_plot.state]]

    widget_list = [[slider, button, button_prev, button_next], [file_textbox]]

    # "gripper_action" plot, labels based on the gripper opening and closing
    plot_list.append([gripper_action_plot.state])
    layout_child = layout(plot_list + widget_list, sizing_mode='fixed')
    curdoc().clear()
    file_textbox.value = file_name.split("\\")[-1]
    #curdoc().remove_root(layout_child)
    #layout_root.children[0] = layout_child
    curdoc().add_root(layout_child)

#iterator = iter(file_name_list) 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:53,代碼來源:stack_player.py

示例11: next_example

# 需要導入模塊: from bokeh import models [as 別名]
# 或者: from bokeh.models import Slider [as 別名]
def next_example(files, action):
    """ load the next example in the dataset
    """
    global file_textbox, button, button_next, button_prev, index, vrep_viz, data, numpy_data
    print("next clicked")
    file_textbox.value = "Processing..."
    renderer = hv.renderer('bokeh')
    if action == 'next':
        index = (index + 1) % len(files)
    else:
        index = (index - 1) % len(files)
    #print("it ", iterator)
    print("index before check", index)
    index = check_errors(files, index, action)
    print("index after check", index)
    print("len", len(files))

    file_name = files[index]
    data, numpy_data = load_example(file_name_list[index])
    rgb_images = numpy_data['rgb_images']
    frame_indices = numpy_data['frame_indices']
    gripper_status = numpy_data['gripper_status']
    action_status = numpy_data['action_status']
    gripper_action_label = numpy_data['gripper_action_label']
    gripper_action_goal_idx = numpy_data['gripper_action_goal_idx']
    print("image loaded")
    print("action goal idx", gripper_action_goal_idx)
    height = int(rgb_images[0].shape[0])
    width = int(rgb_images[0].shape[1])
    start = 0
    end = len(rgb_images)
    print(end)

    def slider_update(attrname, old, new):
        plot.update(slider.value)

    slider = Slider(start=start, end=end, value=0, step=1, title="Frame", width=width)
    slider.on_change('value', slider_update)

    holomap = generate_holo_map(rgb_images, height, width)
    print("generated holomap")
    plot = renderer.get_plot(holomap)
    print("plot rendered")
    gripper_plot, action_plot, gripper_action_plot = load_data_plot(renderer, frame_indices, gripper_status, action_status, gripper_action_label, height, width)
    print("plot loaded..")
    plot_list = [[plot.state], [gripper_plot.state], [action_plot.state]]

    widget_list = [[slider, button, button_prev, button_next], [file_textbox]]

    # "gripper_action" plot, labels based on the gripper opening and closing
    plot_list.append([gripper_action_plot.state])
    layout_child = layout(plot_list + widget_list, sizing_mode='fixed')
    curdoc().clear()
    file_textbox.value = file_name.split("\\")[-1]
    #curdoc().remove_root(layout_child)
    #layout_root.children[0] = layout_child
    curdoc().add_root(layout_child)

#iterator = iter(file_name_list) 
開發者ID:jhu-lcsr,項目名稱:costar_plan,代碼行數:61,代碼來源:vrep_costar_stack.py


注:本文中的bokeh.models.Slider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。