本文整理汇总了Python中bokeh.models.widgets.Slider类的典型用法代码示例。如果您正苦于以下问题:Python Slider类的具体用法?Python Slider怎么用?Python Slider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Slider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DerivViewer
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)])
示例2: init_input
def init_input(self):
# create input widgets only once
self.min_excitation = Slider(
title="Min Excitation", name="min_excitation",
value=min_excitation,
start=min_excitation,
end=max_excitation,
)
self.max_excitation = Slider(
title="Max Excitation", name="max_excitation",
value=max_excitation,
start=min_excitation,
end=max_excitation,
)
self.min_emission = Slider(
title="Min Emission", name="min_emission",
value=min_emission,
start=min_emission,
end=max_emission,
)
self.max_emission = Slider(
title="Max Emission", name="max_emission",
value=max_emission,
start=min_emission,
end=max_emission,
)
self.chrom_class_select = Select(
title="Chromophore",
value='All',
options=['All'] + CHROMOPHORES,
)
示例3: set_sliders
def set_sliders(self):
self.min_excitation = Slider(
title="Min Excitation", name="min_excitation",
value=self.min_excitation.value,
start=min_excitation,
end=max_excitation,
)
self.max_excitation = Slider(
title="Max Excitation", name="max_excitation",
value=self.max_excitation.value,
start=min_excitation,
end=max_excitation,
)
self.min_emission = Slider(
title="Min Emission", name="min_emission",
value=self.min_emission.value,
start=min_emission,
end=max_emission,
)
self.max_emission = Slider(
title="Max Emission", name="max_emission",
value=self.max_emission.value,
start=min_emission,
end=max_emission,
)
示例4: index
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)
示例5: create_layout
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])
示例6: show
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()
示例7: init_controls
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))
示例8: __init__
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]]))
示例9: createControls
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)
示例10: main
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)
示例11: ColumnDataSource
# plotting for normal parametrization
source_point_normal = ColumnDataSource(data=dict(x=[], y=[]))
# 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
示例12: on_text_value_change
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()
示例13: make_dataset
new_src = make_dataset(carriers_to_plot,
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],
示例14: int
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()
示例15: offset
from bokeh.io import curdoc
# the following for the alternate form of page lay-out
#from bokeh.models import HBox, VBox
from bokeh.models.widgets import Slider, Button
from bokeh.models import ColumnDataSource
from bokeh.models.glyphs import MultiLine
# set up params for basic CRF w/ baseline offset (provided by presence of flankers)
contrast = np.arange(0,1,.01)
alpha= 0.6
baseline = 0.3
# interactive tools
nRep = 7 # eventually turn this into an option
redrawButton = Button(label="New Sample", type="success")
CNRslider = Slider(title="CNR", value=1.0, start=0.0, end=2.0)
#https://github.com/bokeh/bokeh/blob/master/tests/glyphs/MultiLine.py
#set up staring data set
CNR=CNRslider.value
response = contrast**alpha + baseline
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
thing=[(np.random.random(contrast.shape)-0.5)/CNR+baseline]