本文整理汇总了Python中bokeh.models.widgets.TextInput.on_change方法的典型用法代码示例。如果您正苦于以下问题:Python TextInput.on_change方法的具体用法?Python TextInput.on_change怎么用?Python TextInput.on_change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.widgets.TextInput
的用法示例。
在下文中一共展示了TextInput.on_change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def main(options, args):
logger = log.get_logger("ginga", options=options)
# create a new plot with default tools, using figure
fig = figure(x_range=[0,600], y_range=[0,600], plot_width=600, plot_height=600,
toolbar_location=None)
viewer = ib.CanvasView(logger)
viewer.set_figure(fig)
def load_file(path):
image = AstroImage(logger)
image.load_file(path)
viewer.set_image(image)
def load_file_cb(attr_name, old_val, new_val):
#print(attr_name, old_val, new_val)
load_file(new_val)
# add a entry widget and configure with the call back
dstdir = options.indir
path_w = TextInput(value=dstdir, title="File:")
path_w.on_change('value', load_file_cb)
if len(args) > 0:
load_file(args[0])
# put the path widget and viewer in a layout and add to the document
curdoc().add_root(vplot(fig, path_w))
示例2: plot
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def plot():
# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))
# Set up plots
plot = Figure(plot_height=400, plot_width=400, title="my sine wave",
tools="crosshair,pan,reset,resize,save,wheel_zoom",
x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])
plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
# Set up widgets
text = TextInput(title="title", value='my sine wave')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1)
# Set up callbacks
def update_title(attrname, old, new):
plot.title = text.value
text.on_change('value', update_title)
def update_data(attrname, old, new):
# Get the current slider values
a = amplitude.value
b = offset.value
w = phase.value
k = freq.value
# Generate the new curve
x = np.linspace(0, 4*np.pi, N)
y = a*np.sin(k*x + w) + b
source.data = dict(x=x, y=y)
for w in [offset, amplitude, phase, freq]:
w.on_change('value', update_data)
# Set up layouts and add to document
inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])
fullformat = HBox(children=[inputs, plot], width=800)
return fullformat, []
示例3: main
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def main(options, args):
logger = log.get_logger("ginga", options=options)
TOOLS = "pan,wheel_zoom,box_select,tap"
# create a new plot with default tools, using figure
fig = figure(x_range=[0,600], y_range=[0,600], plot_width=600, plot_height=600,
tools=TOOLS)
viewer = ib.CanvasView(logger)
viewer.set_figure(fig)
## box_select_tool = fig.select(dict(type=BoxSelectTool))
## box_select_tool.select_every_mousemove = True
#tap_tool = fig.select_one(TapTool).renderers = [cr]
# open a session to keep our local document in sync with server
session = push_session(curdoc())
#curdoc().add_periodic_callback(update, 50)
def load_file(path):
image = AstroImage(logger)
image.load_file(path)
viewer.set_image(image)
def load_file_cb(attr_name, old_val, new_val):
#print(attr_name, old_val, new_val)
load_file(new_val)
# add a entry widget and configure with the call back
dstdir = options.indir
path_w = TextInput(value=dstdir, title="File:")
path_w.on_change('value', load_file_cb)
curdoc().add_root(vplot(fig, path_w))
if len(args) > 0:
load_file(args[0])
# open the document in a browser
session.show()
# run forever
session.loop_until_closed()
示例4: max
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
p.y_range.start = max(nys) + y_buf
p.y_range.end = min(nys) - y_buf
mld = {}
mldf = {}
for nd in nds:
mld.setdefault('xs',[]).append(nd['x'] if len(nd['x']) else [0.0])
mld.setdefault('ys',[]).append(nd['y'] if len(nd['y']) else [0.0])
mld.setdefault('colors',[]).append(plotting.bandcolorf(nd['band']) if len(nd['x']) else 'white')
mld.setdefault('lws',[]).append(2)
mldf.setdefault('xs',[]).extend(nd['x'] if len(nd['x']) else [])
mldf.setdefault('ys',[]).extend(nd['y'] if len(nd['y']) else [])
mldf.setdefault('colors',[]).extend([plotting.bandcolorf(nd['band']) for x in range(len(nd['x']))])
mlobs.data_source.data = mld
circobs.data_source.data = mldf
def bandcb(attrname, old, new):
callback()
def namecb(attrname, old, new):
callback()
namefield.on_change('value', namecb)
bandfield.on_change('value', bandcb)
button.on_click(callback)
# put the button and plot in a layout and add to the document
curdoc().add_root(column(p, row(namefield, bandfield), button))
示例5: CheckboxGroup
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
# 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
plot = Figure(plot_height=400, plot_width=400, tools=toolset,
title="Arc length parametrization",
x_range=[arc_settings.x_min_view, arc_settings.x_max_view],
示例6: reset_ButtonClick
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
reset_button.on_click(lambda x: reset_ButtonClick())
autoscale_button.on_click(lambda x: autoscale_ButtonClick())
channel_button[0].on_click(lambda x: channel_ButtonClick(1))
channel_button[1].on_click(lambda x: channel_ButtonClick(2))
channel_button[2].on_click(lambda x: channel_ButtonClick(3))
channel_button[3].on_click(lambda x: channel_ButtonClick(4))
pulse_capture_button.on_click(lambda x: pulseCapture_ButtonClick())
auto_save_button.on_click(lambda x: autoSave_ButtonClick())
load_button.on_click(lambda x: load_ButtonClick())
force_save_button.on_click(lambda x: forceSave_ButtonClick())
save_PC_button.on_click(lambda x: savePC_ButtonClick())
acq_period_select.on_change("value", acqPeriod_SelectChange)
channel_name_select1.on_change("value", chanNameSelect1_SelectChange)
force_save_filename_input.on_change("value", forceSaveFilename_InputChange)
channel_name_input.on_change("value", channelName_InputChange)
time_range_input.on_change("value", timeRange_InputChange)
trigger_level_input.on_change("value", triggerLevel_InputChange)
save_filepath_input.on_change("value", saveFilepath_InputChange)
load_file_input.on_change("value", loadFile_InputChange)
save_filepath_PC_input.on_change("value", saveFilepath_InputChange) #
save_filename_PC_input.on_change("value", forceSaveFilename_InputChange) #reusing callbacks
#set up layout
doc.title = "Intensity Tracker"
grid = layout([
[channel_button[0],channel_button[1],channel_button[2],channel_button[3]],
[all_on_button, all_off_button, reset_button, autoscale_button],
示例7: StockApp
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
#.........这里部分代码省略.........
top = hist.max()
p = figure(
title=' Histogram',
plot_width=600, plot_height=400,
tools="",
title_text_font_size="16pt",
x_range=[start, end],
y_range=[0, top],
x_axis_label = ' Bins',
y_axis_label = 'Bin Count'
)
p.rect(center, hist / 2.0, width, hist)
return p
def make_plots(self):
self.hist_plots()
def hist_plots(self):
self.hist1 = self.path_plot()
self.hist2 = self.hist_den_plot()
self.hist3 = self.mc_results()
def set_children(self):
self.children = [self.mainrow, self.second_row]
self.mainrow.children = [self.input_box, self.hist1]
self.second_row.children = [self.hist2, self.hist3]
self.input_box.children = [self.ticker1_box, self.ticker2_box, self.ticker3_box,self.ticker4_box,self.ticker5_box]
self.ticker1_box.children =[self.ticker1_select, self.ticker1p_select]
self.ticker2_box.children =[self.ticker2_select, self.ticker2p_select]
self.ticker3_box.children =[self.ticker3_select, self.ticker3_1_select, self.ticker3_2_select]
self.ticker4_box.children =[self.ticker4_select, self.ticker4_1_select, self.ticker4_2_select]
self.ticker5_box.children =[self.button_select]
def input_change(self, obj, attrname, old, new):
if obj == self.ticker4_2_select:
self.ticker4_2 = new
if obj == self.ticker4_1_select:
self.ticker4_1 = new
if obj == self.ticker4_select:
self.ticker4 = new
if obj == self.ticker3_2_select:
self.ticker3_2 = new
if obj == self.ticker3_1_select:
self.ticker3_1 = new
if obj == self.ticker3_select:
self.ticker3 = new
if obj == self.ticker2p_select:
self.ticker2p = new
if obj == self.ticker2_select:
self.ticker2 = new
if obj == self.ticker1p_select:
self.ticker1p = new
if obj == self.ticker1_select:
self.ticker1 = new
if obj == self.button_select:
self.button = new
if 'run' in self.button:
self.make_source()
self.make_plots()
self.set_children()
curdoc().add(self)
#self.make_source()
#self.make_plots()
#self.set_children()
#curdoc().add(self)
def setup_events(self):
super(StockApp, self).setup_events()
if self.ticker1_select:
self.ticker1_select.on_change('value', self, 'input_change')
if self.ticker1p_select:
self.ticker1p_select.on_change('value', self, 'input_change')
if self.ticker2_select:
self.ticker2_select.on_change('value', self, 'input_change')
if self.ticker2p_select:
self.ticker2p_select.on_change('value', self, 'input_change')
if self.ticker3_select:
self.ticker3_select.on_change('value', self, 'input_change')
if self.ticker3_1_select:
self.ticker3_1_select.on_change('value', self, 'input_change')
if self.ticker3_2_select:
self.ticker3_2_select.on_change('value', self, 'input_change')
if self.ticker4_select:
self.ticker4_select.on_change('value', self, 'input_change')
if self.ticker4_1_select:
self.ticker4_1_select.on_change('value', self, 'input_change')
if self.ticker4_2_select:
self.ticker4_2_select.on_change('value', self, 'input_change')
if self.button_select:
self.button_select.on_change('value',self, 'input_change')
@property
def Y(self):
tmpdf = pd.DataFrame(self.main_mc(int(self.ticker3_1),int(self.ticker3),float(self.ticker3_2),self.ticker4_2,float(self.ticker4_1)))
tmpdf.columns = ['Col_' + str(i) for i in xrange(len(tmpdf.columns))]
#print tmpdf
return tmpdf
示例8: on_text_value_change
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput 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()
示例9: plot
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def plot():
# FIGURES AND X-AXIS
fig1 = Figure(title = 'Energy', plot_width = WIDTH, plot_height = HEIGHT, tools = TOOLS)
timeticks = DatetimeTickFormatter(formats=dict(seconds =["%b%d %H:%M:%S"],
minutes =["%b%d %H:%M"],
hours =["%b%d %H:%M"],
days =["%b%d %H:%M"],
months=["%b%d %H:%M"],
years =["%b%d %H:%M %Y"]))
fig1.xaxis.formatter = timeticks
# INPUT WIDGETS
collection_list = CONN[DB].collection_names(include_system_collections=False)
gliders = sorted([platformID for platformID in collection_list if len(platformID)>2])
gliders = Select(title = 'PlatformID', value = gliders[0], options = gliders)
prev_glider = Button(label = '<')
next_glider = Button(label = '>')
glider_controlbox = HBox(children = [gliders, prev_glider, next_glider])
max_amphr = TextInput(title='Max AmpHrs', value='1040')
deadby_date = TextInput(title='Deadby Date', value='')
data_controlbox = HBox(max_amphr, deadby_date, width = 300)
control_box = HBox(glider_controlbox,
data_controlbox)
# DATA VARS
coulombs_raw = ColumnDataSource(dict(x=[],y=[]))
coulombs_ext = ColumnDataSource(dict(x=[],y=[]))
coulombs_per = ColumnDataSource(dict(x=[],y=[]))
# AXIS setup
fig1.yaxis.axis_label = 'Coulombs (AmpHr)'
fig1.extra_y_ranges = {'usage': Range1d(start=0, end=1200)}
# PLOT OBJECTS
fig1.line( 'x', 'y', source = coulombs_raw, legend = 'm_coulombs_amphr_total', color = 'blue')
fig1.circle('x', 'y', source = coulombs_raw, legend = 'm_coulombs_amphr_total', color = 'blue')
fig1.line( 'x', 'y', source = coulombs_ext, legend = 'projected', color = 'red')
#fig1.cross('x', 'y', source = coulombs_ext, legend = 'projected', size=10, color = 'red')
fig1.renderers.append(Span(name = 'maxamp_span', location = int(max_amphr.value), dimension = 'width', line_color= 'green', line_dash='dashed', line_width=2))
fig1.renderers.append(Span(name = 'maxamp_intersect', location = 1000*time.time(), dimension = 'height', line_color= 'green', line_dash='dashed', line_width=2))
fig1.legend[0].location = 'top_left'
fig1.legend[0].legend_padding = 30
# CALLBACK FUNCS
def update_coulombs(attrib,old,new):
g = gliders.value
coulombs_raw.data = load_sensor(g, 'm_coulomb_amphr_total')
#coulombs_per.data = moving_usage(coulombs_raw.data)
update_projection(None,None,None)
def update_projection(attrib,old,new):
g = gliders.value
try:
fig1.select('maxamp_span')[0].location = int(max_amphr.value)
coulombs_ext.data, deadby_date.value = calc_deadby_date(g, int(max_amphr.value))
fig1.select('maxamp_intersect')[0].location = coulombs_ext.data['x'][-1]
except Exception as e:
print('update_projection error',type(e),e)
#GLIDER SELECTS
def glider_buttons(increment):
ops = gliders.options
new_index = ops.index(gliders.value) + increment
if new_index >= len(ops):
new_index = 0
elif new_index < 0:
new_index = len(ops)-1
gliders.value = ops[new_index]
def next_glider_func():
glider_buttons(1)
def prev_glider_func():
glider_buttons(-1)
gliders.on_change('value', update_coulombs)
next_glider.on_click(next_glider_func)
prev_glider.on_click(prev_glider_func)
max_amphr.on_change('value', update_projection)
update_coulombs(None,None,None)
return vplot(control_box, fig1)
示例10: update_slider
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def update_slider(attrname, old, new):
n_samples = int(samples_slider.value)
newdata = get_ends(n_samples)
source_cut.data = dict(newdata.to_dict('list'))
plot.x_range.factors = newdata['aspects'].tolist() # this was missing
plot.y_range.start = min(source_cut.data['importance'])
plot.y_range.end = max(source_cut.data['importance'])
data_table = DataTable(source=source_cut, columns=columns, width=700, height=500)
dataset_select.on_change('value', update_dataset)
exponent_slider.on_change('value', update_dataset)
ratings_box.on_change('value', update_dataset)
samples_slider.on_change('value', update_slider)
# Set up layout
selects = row(dataset_select)
inputs = column(selects, widgetbox(exponent_slider, ratings_box, samples_slider))
table = widgetbox(data_table)
tab1 = Panel(child=table, title="Data")
tab2 = Panel(child=plot, title="Bar Plot")
tabs = Tabs(tabs=[tab1, tab2])
lay = layout([[inputs,tabs],])
# Add to document
curdoc().add_root(lay)
curdoc().title = "Keyword Extraction"
示例11:
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
here=np.loadtxt('here5.csv',str,delimiter='\n')
here=list(here)
here_height=df_counts['numbers']
y_here_height=here_height/2.0
source.data=dict(
x=here[:10],
y=y_here_height[:10],
height=here_height[:10]
)
plot.tools=[hover]
plot.xaxis.major_label_orientation=np.pi/3
plot.x_range.factors=here[:10]
new_height=here_height[:10].values
plot.y_range.end=new_height[0]+200
#plot.rect(x=axis_map[x_axis.value],y=height_map[x_axis.value],height=height_map[x_axis.value]*2.0)
#plot.x_range.on_change('_bounds_as_factors',update)
x_axis.on_change('value',update)
cities.on_change('value',update)
companies.on_change('value',update)
industries.on_change('value',update)
#filters=VBox(x_axis)
#tot=HBox(filters,plot)
#show(tot)
curdoc().add_root(HBox(inputs,plot))
示例12: int
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput 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()
示例13: RadioButtonGroup
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
# initialize controls
# buttons for choosing a sample function
sample_function_type = RadioButtonGroup(labels=fs.function_names, active=fs.function_init)
# here one can choose arbitrary input function
default_function_input = TextInput(value=fs.function_input_init)
default_function_period_start = TextInput(title='period start', value=fs.timeinterval_start_init)
default_function_period_end = TextInput(title='period end', value=fs.timeinterval_end_init)
# slider controlling degree of the fourier series
degree = Slider(title="degree", name='degree', value=fs.degree_init, start=fs.degree_min,
end=fs.degree_max, step=fs.degree_step)
# initialize callback behaviour
degree.on_change('value', degree_change)
default_function_input.on_change('value',
type_input_change) # todo write default functions for any callback, like above
default_function_period_start.on_change('value', type_input_change)
default_function_period_end.on_change('value', type_input_change)
sample_function_type.on_change('active', type_input_change)
# initialize plot
toolset = "crosshair,pan,reset,resize,save,wheel_zoom"
# Generate a figure container
plot = Figure(plot_height=fs.resolution,
plot_width=fs.resolution,
tools=toolset,
title="Fourier Series Approximation",
x_range=[fs.x_min, fs.x_max],
y_range=[fs.y_min, fs.y_max]
)
# Plot the line by the x,y values in the source property
示例14: plotting
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
def plotting(self):
#Tools = [hover, TapTool(), BoxZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool()]
TOOLS="crosshair,pan,wheel_zoom,box_zoom,reset,hover,previewsave"
tab_plots = []
#output_file("test.html")
self.all_elements = []
self.elements_comparison = []
for attr_id, i in zip(self.attribute_ids, range(len(self.attribute_ids))):
"""
create plots for each datafile and put them in a tab.
"""
list_of_datasets = getattr(self, attr_id)
y_axis_units = [x["y_unit"] for x in list_of_datasets]
x_axis_units = [x["x_unit"] for x in list_of_datasets]
figure_obj = figure(plot_width = 1000, plot_height = 800, y_axis_type = "log",
title = attr_id, tools = TOOLS)
#figure_obj.axes.major_label_text_font_size("12pt")
#figure_obj.major_label_text_font_size("12pt")
setattr(self, attr_id+"_"+"figure_obj",figure_obj)
figure_obj.yaxis.axis_label = y_axis_units[0]
figure_obj.xaxis.axis_label = x_axis_units[0]
if not all(x == y_axis_units[0] for x in y_axis_units):
for unit, data in zip(y_axis_units, list_of_datasets):
if not unit == y_axis_units[0]:
figure_obj.extra_y_ranges = {"foo": Range1d(start = np.amin(data["data"]["y"]),
end = np.amax(data["data"]["y"]))}
figure_obj.add_layout(LogAxis(y_range_name = "foo", axis_label = unit), "right")
break
if not all(x == x_axis_units[0] for x in x_axis_units):
for unit, data in zip(x_axis_units, list_of_datasets):
if not unit == x_axis_units[0]:
figure_obj.extra_x_ranges = {"bar": Range1d(start = np.amin(data["data"]["x"]),
end = np.amax(data["data"]["x"]))}
figure_obj.add_layout(LinearAxis(x_range_name = "bar", axis_label = unit), "above")
break
figure_obj.xaxis.axis_label = list_of_datasets[0]["x_unit"]
colour_list = Spectral11 + RdPu9 + Oranges9
colour_indices = [0, 2, 8, 10, 12, 14, 20, 22, 1, 3, 9, 11, 13, 15]
list_of_elements = []
for dataset, color_index in zip(list_of_datasets, colour_indices):
self.all_elements.append(dataset["sample element"]) #strip isotope number
color = colour_list[color_index]
source = ColumnDataSource(data = dataset["data"]) #Datastructure for source of plotting
setattr(self, attr_id+"_"+dataset["sample element"]+"_source", source) #Source element generalized for all plotting
list_of_elements.append(dataset["sample element"])
figure_obj.line("x", "y", source = getattr(self, attr_id+"_"+dataset["sample element"]
+"_source"), line_width = 2, line_color = color,
legend = dataset["sample element"], name = dataset["sample element"],
)
hover = figure_obj.select_one(HoverTool).tooltips = [("element", "@element"), ("(x,y)", "($x, $y)")]
radio_group = RadioGroup(labels = list_of_elements, active=0)
"""
Need to fetch default variables from input file and replace DEFAULT
Block of code produces the layout of buttons and callbacks
"""
#Calculations on the dataset
text_input_rsf = TextInput(value = "default", title = "RSF (at/cm^3): ")
do_integral_button = Button(label = "Calibration Integral")
smoothing_button = Button(label = "Smoothing on selected curve")
text_input_sputter = TextInput(value = "default", title = "Sputter speed: float unit")
text_input_crater_depth = TextInput(value = "default", title = "Depth of crater in: float")
radio_group.on_change("active", lambda attr, old, new: None)
text_input_xval_integral = TextInput(value = "0", title = "x-value for calibration integral ")
text_input_yval_integral = TextInput(value = "0", title = "y-value for calibration integral ")
#Save files for later use
save_flexDPE_button = Button(label = "Save element for FlexPDE")
#.........这里部分代码省略.........
示例15: dict
# 需要导入模块: from bokeh.models.widgets import TextInput [as 别名]
# 或者: from bokeh.models.widgets.TextInput import on_change [as 别名]
"PARAMS: offset: %s amplitude: %s", offset.value,
amplitude.value
)
source.data = dict(x=x, y=y)
update_data()
def input_change(attrname, old, new):
"""Executes whenever the input form changes.
It is responsible for updating the plot, or anything else you want.
Args:
attrname : the attr that changed
old : old value of attr
new : new value of attr
"""
update_data()
plot.title = text.value
# Text box event registration
text.on_change('value', input_change)
# Slider event registration
for w in [offset, amplitude, phase, freq]:
w.on_change('value', input_change)
# put ourselves in the document
curdoc().add(hbox)