当前位置: 首页>>代码示例>>Python>>正文


Python Slider.on_change方法代码示例

本文整理汇总了Python中bokeh.models.widgets.Slider.on_change方法的典型用法代码示例。如果您正苦于以下问题:Python Slider.on_change方法的具体用法?Python Slider.on_change怎么用?Python Slider.on_change使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.widgets.Slider的用法示例。


在下文中一共展示了Slider.on_change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DerivViewer

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
class DerivViewer(object):

    def __init__(self):
        self.xs = np.linspace(-2.0, 2.0, 100)
        self.ys = test_func(self.xs)

        self.source1 = ColumnDataSource(data=dict(xs=self.xs,
                                                  ys=self.ys))
        a = 0
        txs, tys = get_tangentdata(a)
        self.source2 = ColumnDataSource(data=dict(txs=txs,
                                                  tys=tys))
        self.source3 = ColumnDataSource(data=dict(x=[a], y=[test_func(a)]))
        self.fig = figure(title='view tangent line',
                          x_range=(-2.0, 2.0),
                          y_range=(-0.2, 1.2))
        self.fig.line('xs', 'ys', source=self.source1)
        self.fig.line('txs', 'tys', source=self.source2, color='orange')
        self.fig.circle('x', 'y', source=self.source3, color='red')

        self.slider = Slider(title='position',
                             value=0,
                             start=-1.5,
                             end=1.5,
                             step=0.1)
        self.slider.on_change('value', self.update_data)
        self.plot = column(self.slider, self.fig)

    def update_data(self, attr, old, new):
        a = self.slider.value
        txs, tys = get_tangentdata(a)
        self.source2.data = dict(txs=txs, tys=tys)
        self.source3.data = dict(x=[a], y=[test_func(a)])
开发者ID:terasakisatoshi,项目名称:PythonCode,代码行数:35,代码来源:deriv.py

示例2: index

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
def index():  
    slider_freq = Slider(orientation="horizontal", start=1, end=5, value=1, step=1, name="freq1", title = "Frequency")
    slider_freq.on_change('value', eventHandler, 'input_change')

    layout = HBox(
        children = [slider_freq]
    )
    script, div = components(layout)

    return render_template('index.html', script = script, div = div)
开发者ID:fahad623,项目名称:FlaskWebProject2,代码行数:12,代码来源:app2.py

示例3: create_layout

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
    def create_layout(self):

        # create figure
        self.x_range = Range1d(start=self.model.map_extent[0],
                               end=self.model.map_extent[2], bounds=None)
        self.y_range = Range1d(start=self.model.map_extent[1],
                               end=self.model.map_extent[3], bounds=None)

        self.fig = Figure(tools='wheel_zoom,pan', x_range=self.x_range,
                          y_range=self.y_range)
        self.fig.plot_height = 660
        self.fig.plot_width = 990
        self.fig.axis.visible = False

        # add tiled basemap
        self.tile_source = WMTSTileSource(url=self.model.basemap)
        self.tile_renderer = TileRenderer(tile_source=self.tile_source)
        self.fig.renderers.append(self.tile_renderer)

        # add datashader layer
        self.image_source = ImageSource(url=self.model.service_url,
                                        extra_url_vars=self.model.shader_url_vars)
        self.image_renderer = DynamicImageRenderer(image_source=self.image_source)
        self.fig.renderers.append(self.image_renderer)

        # add ui components
        axes_select = Select.create(name='Axes',
                                        options=self.model.axes)
        axes_select.on_change('value', self.on_axes_change)

        field_select = Select.create(name='Field', options=self.model.fields)
        field_select.on_change('value', self.on_field_change)

        aggregate_select = Select.create(name='Aggregate',
                                         options=self.model.aggregate_functions)
        aggregate_select.on_change('value', self.on_aggregate_change)

        transfer_select = Select.create(name='Transfer Function',
                                        options=self.model.transfer_functions)
        transfer_select.on_change('value', self.on_transfer_function_change)

        basemap_select = Select.create(name='Basemap', value='Toner',
                                       options=self.model.basemaps)
        basemap_select.on_change('value', self.on_basemap_change)

        opacity_slider = Slider(title="Opacity", value=100, start=0,
                                end=100, step=1)
        opacity_slider.on_change('value', self.on_opacity_slider_change)

        controls = [axes_select, field_select, aggregate_select,
                    transfer_select, basemap_select, opacity_slider]
        self.controls = HBox(width=self.fig.plot_width, children=controls)
        self.layout = VBox(width=self.fig.plot_width,
                           height=self.fig.plot_height,
                           children=[self.controls, self.fig])
开发者ID:WilfR,项目名称:datashader,代码行数:57,代码来源:dashboard.py

示例4: show

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
def show(sample_size):
    global session
    global scatter_plot
    global source
    global pie_chart_source
    global line_chart_source
    global slider
    DB.__init__(sample_size)
    min_time = DB.min_time()
    max_time = DB.max_time()
    print min_time
    print min_time
    xs, ys, color, time = DB.get_current()
    xs = [xs[i] for i,v in enumerate(time) if time[i] == min_time]
    ys = [ys[i] for i,v in enumerate(time) if time[i] == min_time]
    color = [color[i] for i,v in enumerate(time) if time[i] == min_time]

    time_dict = Counter(time)
    pie_chart_source = ColumnDataSource(data=ChartMath.compute_color_distribution('x', 'y', 'color', color))
    line_chart_source = ColumnDataSource(data=dict(x=[key for key in time_dict], y=[time_dict[key] for key in time_dict]))
    source = ColumnDataSource(data=dict(x=xs, y=ys, color=color))

    scatter_plot = Figure(plot_height=800,
                          plot_width=1200,
                          title="Plot of Voters",
                          tools="pan, reset, resize, save, wheel_zoom",
                          )

    scatter_plot.circle('x', 'y', color='color', source=source, line_width=0, line_alpha=0.001, fill_alpha=0.5, size=15)
    scatter_plot.patches('x', 'y', source=state_source, fill_alpha=0.1, line_width=3, line_alpha=1)

    scatter_plot.x_range.on_change('end', update_coordinates)
    line_chart = Figure(title="Distribution over Time", plot_width=350, plot_height=350)
    line_chart.line(x='x', y='y', source=line_chart_source)
    pie_chart_plot = Figure(plot_height=350,
                            plot_width=350,
                            title="Voter Distribution",
                            x_range=(-1, 1),
                            y_range=(-1, 1))
    pie_chart_plot.wedge(x=0, y=0, source=pie_chart_source, radius=1, start_angle="x", end_angle="y", color="color")
    slider = Slider(start=min_time, end=max_time, value=min_time, step=1, title="Time")

    slider.on_change('value', update_coordinates)
    h = hplot(scatter_plot, vplot(pie_chart_plot, line_chart))
    vplot(slider, h, width=1600, height=1800)
    session = push_session(curdoc())
    session.show()
    #script = autoload_server(scatter_plot, session_id=session.id)
    session.loop_until_closed()
开发者ID:rahulpalamuttam,项目名称:SparkViz,代码行数:51,代码来源:main.py

示例5: init_controls

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
	def init_controls(self):
		btnStop = Button(label="Stop", type="danger")
		btnStart = Button(label="Start", type="success")	
		
		btnStop.on_click(self.handle_btnStop_press)
		btnStart.on_click(self.handle_btnStart_press)
				
		curdoc().add_root(btnStop)
		curdoc().add_root(btnStart)
		

		sliderHPThreshold = Slider(start=0, end=500, value=100, step=1, title="High pass threshold")
			
		sliderHPThreshold.on_change('value', self.onChangeHPThreshold)
		curdoc().add_root(vplot(sliderHPThreshold))
开发者ID:ricsirke,项目名称:SoundFreqPlotter,代码行数:17,代码来源:ui.py

示例6: main

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
def main():
    state_xs, state_ys = get_us_state_outline()
    left, right = minmax(state_xs)
    bottom, top = minmax(state_ys)
    plot = Figure(title=TITLE, plot_width=1000,
                  plot_height=700,
                  tools="pan, wheel_zoom, box_zoom, reset",
                  x_range=Range1d(left, right),
                  y_range=Range1d(bottom, top),
                  x_axis_label='Longitude',
                  y_axis_label='Latitude')

    plot_state_outline(plot, state_xs, state_ys)

    density_overlay = DensityOverlay(plot, left, right, bottom, top)
    density_overlay.draw()

    grid_slider = Slider(title="Details", value=density_overlay.gridcount,
                         start=10, end=100, step=10)
    grid_slider.on_change("value", density_overlay.grid_change_listener)

    radiance_slider = Slider(title="Min. Radiance",
                             value=density_overlay.radiance,
                             start=np.min(density_overlay.rad),
                             end=np.max(density_overlay.rad), step=10)
    radiance_slider.on_change("value", density_overlay.radiance_change_listener)

    listener = ViewListener(plot, density_overlay, name="viewport")

    plot.x_range.on_change("start", listener)
    plot.x_range.on_change("end", listener)
    plot.y_range.on_change("start", listener)
    plot.y_range.on_change("end", listener)

    backends = ["CPU", "HSA"]
    default_value = backends[kde.USE_HSA]
    backend_select = Select(name="backend", value=default_value,
                            options=backends)
    backend_select.on_change('value', density_overlay.backend_change_listener)

    doc = curdoc()
    doc.add(VBox(children=[plot, grid_slider, radiance_slider, backend_select]))
    doc.add_periodic_callback(density_overlay.periodic_callback, 0.5)
开发者ID:ContinuumIO,项目名称:numba-hsa-examples,代码行数:45,代码来源:lightning_app.py

示例7: RotationViewer

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
class RotationViewer(object):

    def __init__(self):
        xs = np.linspace(-np.pi, np.pi, 11)
        ys = xs
        Xs, Ys = np.meshgrid(xs, ys)
        self.Xs, self.Ys = Xs.flatten(), Ys.flatten()
        initdegree = 0
        mat = rot_mat(initdegree)
        transXs, transYs = mat @ np.array([self.Xs, self.Ys])

        TOOLS = "pan,lasso_select,save,reset"

        self.source = ColumnDataSource(data=dict(Xs=self.Xs, Ys=self.Ys,
                                                 transXs=transXs,
                                                 transYs=transYs))

        self.fig = figure(tools=TOOLS, title="target",
                          x_range=(-np.pi*np.sqrt(2)-1, np.pi*np.sqrt(2)+1),
                          y_range=(-np.pi*np.sqrt(2)-1, np.pi*np.sqrt(2)+1))
        self.fig.circle('Xs', 'Ys', source=self.source)

        self.transfig = figure(tools=TOOLS, title="transformed",
                               x_range=self.fig.x_range, y_range=self.fig.y_range)
        self.transfig.circle('transXs', 'transYs', source=self.source, size=6)

        self.rot_param = Slider(title="degree", value=0,
                                start=0, end=360, step=1)
        self.rot_param.on_change('value', self.update_data)

        self.plot = column(self.rot_param, gridplot([[self.fig, self.transfig]]))

    def update_data(self, attr, old, new):
        mat = rot_mat(self.rot_param.value)
        transXs, transYs = mat @ np.array([self.Xs, self.Ys])
        self.source.data = dict(Xs=self.Xs, Ys=self.Ys,
                                transXs=transXs, transYs=transYs)
        self.transfig.title.text = "degree {}".format(self.rot_param.value)
开发者ID:terasakisatoshi,项目名称:PythonCode,代码行数:40,代码来源:rotmat.py

示例8: slider_change

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
def slider_change(attr, old, new):
    global interval
    interval = (10 * max_interval + min_interval + new * (min_interval - max_interval)) / 9
    if play:
        curdoc().remove_periodic_callback(update)
        curdoc().add_periodic_callback(update, interval)


def button_group_click(new):
    global play
    if new == 0: # play
        play = True
        curdoc().add_periodic_callback(update, interval)
    else:
        play = False
        curdoc().remove_periodic_callback(update)

def button_click():
    global X, step
    step = 1
    X = np.copy(X_init)
    redraw()


slider.on_change("value", slider_change)
button_group.on_click(button_group_click)
button.on_click(button_click)

session.show(row(wb, p1, p2))
session.loop_until_closed()
开发者ID:alexschlueter,项目名称:ba,代码行数:32,代码来源:rmclt.py

示例9: ColumnDataSource

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
# plotting for arc length parametrization
source_point_arc = ColumnDataSource(data=dict(x=[], y=[]))


# initialize controls
# choose between original and arc length parametrization
parametrization_input = CheckboxGroup(labels=['show original parametrization',
                                              'show arc length parametrization'],
                                      active=[0, 1])
parametrization_input.on_click(parametrization_change)
# slider controlling the current parameter t
t_value_input = Slider(title="parameter t", name='parameter t', value=arc_settings.t_value_init,
                       start=arc_settings.t_value_min, end=arc_settings.t_value_max,
                       step=arc_settings.t_value_step)
t_value_input.on_change('value', t_value_change)
# text input for the x component of the curve
x_component_input = TextInput(value=arc_settings.x_component_input_msg, title="curve x")
x_component_input.on_change('value', curve_change)
# text input for the y component of the curve
y_component_input = TextInput(value=arc_settings.y_component_input_msg, title="curve y")
y_component_input.on_change('value', curve_change)
# dropdown menu for selecting one of the sample curves
sample_curve_input = Dropdown(label="choose a sample function pair or enter one below",
                              menu=arc_settings.sample_curve_names)
sample_curve_input.on_click(sample_curve_change)


# initialize plot
toolset = "crosshair,pan,reset,resize,save,wheel_zoom"
# Generate a figure container
开发者ID:BenjaminRueth,项目名称:Visualization,代码行数:32,代码来源:arc_app.py

示例10: on_text_value_change

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]

def on_text_value_change(attr, old, new):
    try:
        global expr
        expr = sy.sympify(new, dict(x=xs))
    except (sy.SympifyError, TypeError, ValueError) as exception:
        dialog.content = str(exception)
        dialog.visible = True
    else:
        update_data()


dialog = Dialog(title="Invalid expression")

slider = Slider(start=1, end=20, value=order, step=1, title="Order", callback_policy="mouseup")
slider.on_change("value", on_slider_value_change)

text = TextInput(value=str(expr), title="Expression:")
text.on_change("value", on_text_value_change)

inputs = WidgetBox(children=[slider, text], width=400)
layout = Column(children=[inputs, plot, dialog])
update_data()
document.add_root(layout)
session.show(layout)

if __name__ == "__main__":
    print("\npress ctrl-C to exit")
    session.loop_until_closed()
开发者ID:jbcrail,项目名称:bokeh,代码行数:31,代码来源:taylor_server.py

示例11: CheckboxGroup

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
                           range_start = range_select.value[0],
                           range_end = range_select.value[1],
                           bin_width = binwidth_select.value)

    src.data.update(new_src.data)


# CheckboxGroup to select carrier to display
carrier_selection = CheckboxGroup(labels=available_carriers, active = [0, 1])
carrier_selection.on_change('active', update)

# Slider to select width of bin
binwidth_select = Slider(start = 1, end = 30, 
                     step = 1, value = 5,
                     title = 'Delay Width (min)')
binwidth_select.on_change('value', update)

# RangeSlider control to select start and end of plotted delays
range_select = RangeSlider(start = -60, end = 180, value = (-60, 120),
                           step = 5, title = 'Delay Range (min)')
range_select.on_change('value', update)


# Find the initially selected carrieres
initial_carriers = [carrier_selection.labels[i] for i in carrier_selection.active]

src = make_dataset(initial_carriers,
                  range_start = range_select.value[0],
                  range_end = range_select.value[1],
                  bin_width = binwidth_select.value)
开发者ID:droumis,项目名称:Bokeh-Python-Visualization,代码行数:32,代码来源:delay_histogram.py

示例12: range

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
    alpha = alphaSlider.value
    offset = offsetSlider.value
    response.data['y'] = contrast**alpha + offset
    response_plus_noise.data['y'] = contrast**alpha + offset + (np.random.random(contrast.shape)-0.5)/CNR
    baseline.data['y'] = offset*np.ones(contrast.shape)
    baseline_plus_noise.data['y'] = offset+(np.random.random(contrast.shape)-0.5)/CNR 
    p1.title = 'CNR = %2.1f' %CNR
    # sim some data
    data = np.zeros([nRep,3])
    for iRep in range(nRep):
        stim = offset + np.array([0.08,0.16,0.32])**alpha + (np.random.random((1,3))-0.5)/CNR
        fonly = offset + (np.random.random()-0.5)/CNR
        data[iRep,:] = stim - fonly
    # and push to plots
    for iC,c in enumerate([0.08,0.16,0.32]):
        data_all[iC].data['y'] = data[:,iC]
        data_all[iC].data['x'] = c*np.ones([nRep])
    data_means.data['y'] = np.mean(data,axis=0)
    for iC,c in enumerate([0.08,0.16,0.32]):
        data_eb[iC].data['y'] = np.mean(data[:,iC]) + np.std(data[:,iC])/np.sqrt(nRep)*np.array([-1,1])  

CNRslider.on_change('value',update)
nREPslider.on_change('value',update)
alphaSlider.on_change('value',update)
offsetSlider.on_change('value',update)
redrawButton.on_change('clicks',update)

    


开发者ID:andreagrant,项目名称:bokeh,代码行数:28,代码来源:CRF.py

示例13: widgetDIMS

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
class widgetDIMS(object):

    column_names_rocks = ['kclay', 'muclay', 'rhoclay',
                          'knonclay', 'munonclay', 'rhononclay',
                          'vclay', 'phi', 'dryEk', 'dryPk', 'dryEg', 'dryPg']
    column_names_fluids = ['Name', 'ko', 'rhoo', 'kw', 'rhow', 'kg', 'rhog', 'so', 'sw', 'sg'   ]
    column_names_pres = ['Name', 'OB_Grad', 'init_Pres', 'curr_Pres']
    column_names_output = ['rock', 'fluid', 'Vp', 'Vs', 'rho', 'other']

    def __init__(self,init_depth,file_rocks,file_fluids,file_prespfs,fdi=None):
        '''
        :param init_depth: Initial depth to model (TVDSS).
        :param file_rocks: File with input mineral parameters.
        :param file_fluids: File with input fluid parameters.
        :param file_prespfs: File with input pressure profiles.
        :keyword dependents: A list of geoPy widgets which need to be updated when widgetDIMS is changed.
        '''
        # Initial Data
        self.df_rocks = pd.read_csv(file_rocks, skipinitialspace=True)
        self.df_fluids = pd.read_csv(file_fluids, skipinitialspace=True)
        self.df_pres = pd.read_csv(file_prespfs, skipinitialspace=True)
        self.init_depth = init_depth  # mTVDSS
        self.pagewidth = 1000  # pixels
        self.fdi = fdi

        # Setup Sources
        self.CDS_rocks = ColumnDataSource(self.df_rocks)
        self.CDS_fluids = ColumnDataSource(self.df_fluids)
        self.CDS_pres = ColumnDataSource(self.df_pres)
        self.CDS_out = ColumnDataSource(data=dict())
        # Extract Names
        self.odict_rocks = self.__odictIndex(self.df_rocks.Name.tolist())
        self.odict_fluids = self.__odictIndex(self.df_fluids.Name.tolist())
        self.odict_pres = self.__odictIndex(self.df_pres.Name.tolist())
        # Setup widgets
        self.createTableWidgets()
        self.createControls()
        self.createLayout()

        self.on_selection_change('value',1,1)

    def __odictIndex(self,keys):
        out = ExtOrderedDict()
        for ind,key in enumerate(keys):
            out[key] = ind
        return out

    def createTableWidgets(self):
        self.col_rocks =  [TableColumn(field=Ci, title=Ci) for Ci in self.column_names_rocks]
        self.col_fluids = [TableColumn(field=Ci, title=Ci) for Ci in self.column_names_fluids]
        self.col_pres =   [TableColumn(field=Ci, title=Ci) for Ci in self.column_names_pres]
        self.col_out =    [TableColumn(field=Ci, title=Ci) for Ci in self.column_names_output]
        #Setup table widgets
        tablekwargs = {'width': self.pagewidth, 'editable': True}
        self.TW_rocks =  DataTable(source=self.CDS_rocks,  columns=self.col_rocks,  **tablekwargs)
        self.TW_fluids = DataTable(source=self.CDS_fluids, columns=self.col_fluids, **tablekwargs)
        self.TW_pres =   DataTable(source=self.CDS_pres,   columns=self.col_pres,   **tablekwargs)
        self.TW_out =    DataTable(source=self.CDS_out,    columns=self.col_out,    **tablekwargs)

    def createControls(self):
        # Setup Select Panes and Input Widgets

        #Obr - Overburden rock  #ResR - Reservoir rock
        #Obf - Oberburden fluid #Resf - Reservoir fluid
        self.selectObr = Select(value=self.odict_rocks.keyslist()[0], options=self.odict_rocks.keyslist(),
                                title="Rock  Model")
        self.selectResR = Select(value=self.odict_rocks.keyslist()[0], options=self.odict_rocks.keyslist(),
                                 title="Rock  Model")
        self.selectObf = Select(value=self.odict_fluids.keyslist()[0], options=self.odict_fluids.keyslist(),
                                title="Fluid Model")
        self.selectResf = Select(value=self.odict_fluids.keyslist()[0], options=self.odict_fluids.keyslist(),
                                 title="Fluid Model")
        self.selectPres = Select(value=self.odict_pres.keyslist()[0], options=self.odict_pres.keyslist(),
                                 title="Pressure Scenario")

        self.slideDepth = Slider(start=0, end=10000, value=self.init_depth, step=10, title='Depth (TVDSS)',
                                 callback_policy='mouseup')

        self.selectObr.on_change('value', self.on_selection_change)
        self.selectResR.on_change('value', self.on_selection_change)
        self.selectObf.on_change('value', self.on_selection_change)
        self.selectResf.on_change('value', self.on_selection_change)
        self.selectPres.on_change('value', self.on_selection_change)
        self.slideDepth.on_change('value', self.on_selection_change)

    def createLayout(self):
        # Layout of Page
        self.inputTab1 = Panel(child=self.TW_rocks,  title='Rock Models')
        self.inputTab2 = Panel(child=self.TW_fluids, title='Fluid Mixes')
        self.inputTab3 = Panel(child=self.TW_pres,   title='Pressure Scenarios')
        self.inputTab4 = Panel(child=self.TW_out,    title='Model Calculations')

        self.inputTabs = Tabs(tabs=[self.inputTab1, self.inputTab2,
                                    self.inputTab3, self.inputTab4],
                                    width=self.pagewidth, height=200)

        textrowob = Div(text="<h1> Overburden: </h1>")
        selectrowob = row(self.selectObr, self.selectObf, width=500, height=50, sizing_mode="scale_both")
        textrowres = Div(text="<h1> Reservoir: </h1>")
        selectrowres = row(self.selectResR, self.selectResf, width=500, height=50, sizing_mode="scale_both")
#.........这里部分代码省略.........
开发者ID:trhallam,项目名称:geoPy,代码行数:103,代码来源:dims.py

示例14: int

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
    order = int(new)
    update_data()

def on_text_value_change(attr, old, new):
    try:
        global expr
        expr = sy.sympify(new, dict(x=xs))
    except (sy.SympifyError, TypeError, ValueError) as exception:
        dialog.content = str(exception)
        dialog.visible = True
    else:
        update_data()

dialog = Dialog(title="Invalid expression")

slider = Slider(start=1, end=20, value=order, step=1, title="Order:")
slider.on_change('value', on_slider_value_change)

text = TextInput(value=str(expr), title="Expression:")
text.on_change('value', on_text_value_change)

inputs = HBox(children=[slider, text])
layout = VBox(children=[inputs, plot, dialog])
update_data()
document.add_root(layout)
session.show(layout)

if __name__ == "__main__":
    print("\npress ctrl-C to exit")
    session.loop_until_closed()
开发者ID:0-T-0,项目名称:bokeh,代码行数:32,代码来源:taylor_server.py

示例15: range

# 需要导入模块: from bokeh.models.widgets import Slider [as 别名]
# 或者: from bokeh.models.widgets.Slider import on_change [as 别名]
    response_plus_noise = response + (np.random.random(contrast.shape)-0.5)/CNR
    # sim some data
    data = np.zeros([nRep,3])
    for iRep in range(nRep):
        stim = baseline + np.array([0.08,0.16,0.32])**alpha + (np.random.random((1,3))-0.5)/CNR
        fonly = baseline + np.random.random()-0.5
        data[iRep,:] = stim - fonly
       
    #p1.line([0,1], [baseline,baseline], line_dash=[8,8], color = 'green')
    #p1.line(contrast, (np.random.random(contrast.shape)-0.5)/CNR+baseline, alpha=0.6, color='green')
    #p1.line(contrast,response, alpha=0.6, color='black')
    #p1.line(contrast,response_plus_noise, alpha=0.6, color='black')
    sourceLine.data['xs']=[[0,1],contrast,contrast,contrast]
    sourceLine.data['ys']=[[baseline,baseline],[(np.random.random(contrast.shape)-0.5)/CNR+baseline],response, response_plus_noise]
 

    p1.title = 'CNR = %2.1f' %CNR

    p2.line([0,1], [0,0], line_dash=[8,8], color = 'green')
    for iC,c in enumerate([0.08,0.16,0.32]):
        p2.circle(c*np.ones([nRep]), data[:,iC], color='red', fill_alpha=0.3, line_alpha=0.3)
    for iC,c in enumerate([0.08,0.16,0.32]):
        p2.circle(c, np.mean(data[:,iC]), color='red')
        p2.line([c,c], np.mean(data[:,iC]) + np.std(data[:,iC])/np.sqrt(nRep)*np.array([-1,1]), color='red')
    
CNRslider.on_change('value',update)

    


开发者ID:andreagrant,项目名称:bokeh,代码行数:28,代码来源:CRF_hack.py


注:本文中的bokeh.models.widgets.Slider.on_change方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。