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


Python widgets.TextInput类代码示例

本文整理汇总了Python中bokeh.models.widgets.TextInput的典型用法代码示例。如果您正苦于以下问题:Python TextInput类的具体用法?Python TextInput怎么用?Python TextInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

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))
开发者ID:Cadair,项目名称:ginga,代码行数:30,代码来源:example2.py

示例2: make_inputs

    def make_inputs(self):

        self.ticker1_select = Select(
            name='ticker1',
            title='Portfolio:',
            value='MSFT',
            options = ['INTC', 'Tech Basket', 'IBB', 'IGOV']
        )
        self.ticker2_select = Select(
            name='ticker2',
            title='Risk/Performance Metric:',
            value='Price',
            options=['Daily Prices', 'Daily Returns', 'Daily Cum Returns', 'Max DD Percentage', 'Percentage Up Days', 'Rolling 95% VaR', 'Rolling Ann. Volatility', 'Rolling Worst Dly. Loss', 'Ann. Sharpe Ratio']
        )
        self.ticker3_select = TextInput(
            name='ticker3',
            title='Window Size:',
            value='63'
        )
        self.ticker4_select = TextInput(
            name='ticker4',
            title='Start Date:',
            value='2010-01-01'
        )
        self.ticker5_select = TextInput(
            name='ticker5',
            title='End Date:',
            value='2015-08-01'
        )
开发者ID:steve98654,项目名称:bokeh-demos,代码行数:29,代码来源:risk_app.py

示例3: make_inputs

    def make_inputs(self):

        self.ticker1_select = TextInput(
            name='ticker1',
            title='Drift Function:',
            value='1.2*(1.1-x)',
        )
        self.ticker1p_select = TextInput(
            name='ticker1p',
            title='Drift Derivative:',
            value='-1.2',
        )
        self.ticker2_select = TextInput(
            name='ticker2',
            title='Volatility Function:',
            value='4.0',
        )
        self.ticker2p_select = TextInput(
            name='ticker2p',
            title='Volatility Derivative:',
            value='0.0',
        )
        self.ticker3_select = TextInput(
            name='ticker3',
            title='Number of Paths:',
            value='500'
        )
        self.ticker3_1_select = TextInput(
            name='ticker3_1',
            title='Number of Points:',
            value='252'
        )
        self.ticker3_2_select = TextInput(
            name='ticker3_2',
            title='Time Step:',
            value='0.01'
        )
        self.ticker4_select = TextInput(
            name='ticker4',
            title='Histogram Line:',
            value='100'
        )
        self.ticker4_1_select = TextInput(
            name='ticker4_1',
            title='Initial Value:',
            value='1.01'
        )
        self.ticker4_2_select = Select(
            name='ticker4_2',
            title='MC Scheme:',
            value='Milstein',
            options=['Euler','Milstein', 'Pred/Corr']
        )
        self.button_select = TextInput(
            name='button',
            title='Type any word containing "run" to run Simulation ',
            value = ''
        )
开发者ID:steve98654,项目名称:bokeh-demos,代码行数:58,代码来源:mc_bokeh.py

示例4: plot

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, []
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:53,代码来源:plot_sandbox.py

示例5: main

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() 
开发者ID:Cadair,项目名称:ginga,代码行数:46,代码来源:example1.py

示例6: ColumnDataSource

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
plot = Figure(plot_height=400, plot_width=400, tools=toolset,
              title="Arc length parametrization",
开发者ID:BenjaminRueth,项目名称:Visualization,代码行数:31,代码来源:arc_app.py

示例7: Select

acq_period_select = Select(title="Acquisition Period (s):", value="100",
                        options=[".5","1","10","100","300","1000"])
num_avgs_select = Select(title="Number of Points to Average:", value="100", 
                        options=["100","1000","10000","100000","1000000"])
channel_name_select1 = Select(title='Channel Select:', value="Channel 1",
                        options =["Channel 1", "Channel 2", "Channel 3", "Channel 4"])
channel_name_select2 = Select(title='Channel Names:', value="Channel 1",
                        options =["Channel 1", "Channel 2", "Channel 3", "Channel 4"])
number_points_select = Select(title="Number of Points", value="100",
                        options =["100", "200", "500", "1000", "5000", "10000", "100000", "1000000"])
load_plot_type_select = Select(title="Plot Type:", value="Multi-plot",
            options =["Multi-plot", "Pulse Capture Plot"])


# Text inputs
channel_name_input = TextInput(title="Name:")
trigger_level_input = TextInput(value="1", title="Trigger Level (V)")
time_range_input = TextInput(value="1000", title="Time Range (us)")
load_file_input = TextInput(value=home_dir, title="Load file:")
save_filepath_input = TextInput(value=home_dir, title="Save to directory:")
force_save_filename_input = TextInput(value=str(dt.now(PT).year)+"_"+str(dt.now(PT).month)+"_"+str(dt.now(PT).day)+".h5", 
                                title="Save as filename:")
save_filepath_PC_input = TextInput(value=home_dir, title="Save to directory:")
save_filename_PC_input = TextInput(value="PC_"+str(dt.now(PT).year)+"_"+str(dt.now(PT).month)+"_"+str(dt.now(PT).day)+".h5",
                                title="Save as filename:")


#setup event handlers
all_off_button.on_click(lambda x: allOff_ButtonClick())
all_on_button.on_click(lambda x: allOn_ButtonClick())
reset_button.on_click(lambda x: reset_ButtonClick())
开发者ID:HaeffnerLab,项目名称:Haeffner-Lab-LabRAD-Tools,代码行数:31,代码来源:IntensityTracker.py

示例8: plot

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)
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:90,代码来源:plot_energy.py

示例9: 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()
开发者ID:jbcrail,项目名称:bokeh,代码行数:28,代码来源:taylor_server.py

示例10: 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()
开发者ID:0-T-0,项目名称:bokeh,代码行数:30,代码来源:taylor_server.py

示例11: plot

def plot():

    # FIGURES AND X-AXIS
    fig1 = Figure(title = 'Dive Profile',  plot_width = WIDTH, plot_height = HEIGHT, tools = TOOLS)
    fig2 = Figure(title = 'Dive Controls', plot_width = WIDTH, plot_height = HEIGHT, tools = TOOLS, x_range=fig1.x_range)
    fig3 = Figure(title = 'Attitude',      plot_width = WIDTH, plot_height = HEIGHT, tools = TOOLS, x_range=fig1.x_range)
    figs = gridplot([[fig1],[fig2],[fig3]])

    # Formatting x-axis
    timeticks = DatetimeTickFormatter(formats=dict(seconds =["%b%d %H:%M:%S"],
                                                   minutes =["%b%d %H:%M"],
                                                   hourmin =["%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
    fig2.xaxis.formatter = timeticks
    fig3.xaxis.formatter = timeticks

    # removing gridlines
    fig1.xgrid.grid_line_color = None
    fig1.ygrid.grid_line_color = None
    fig2.xgrid.grid_line_color = None
    fig2.ygrid.grid_line_color = None
    fig3.xgrid.grid_line_color = None
    fig3.ygrid.grid_line_color = None

    # 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], height=80)

    chunkations = Select(title = 'Chunkation', value = 'segment', options = ['segment', '24hr', '30days', '-ALL-'])
    chunk_indicator = TextInput(title = 'index', value = '0')
    prev_chunk = Button(label = '<')
    next_chunk = Button(label = '>')
    chunk_ID   = PreText(height=80)
    chunk_controlbox = HBox(chunkations,
                            HBox(chunk_indicator, width=25),
                            prev_chunk, next_chunk,
                            chunk_ID,
                            height = 80)

    control_box = HBox(glider_controlbox,
                        chunk_controlbox)

    # DATA VARS
    deadby_date = ''
    depth    = ColumnDataSource(dict(x=[],y=[]))
    vert_vel = ColumnDataSource(dict(x=[],y=[]))

    mbpump   = ColumnDataSource(dict(x=[],y=[]))
    battpos  = ColumnDataSource(dict(x=[],y=[]))
    pitch    = ColumnDataSource(dict(x=[],y=[]))

    mfin      = ColumnDataSource(dict(x=[],y=[]))
    cfin      = ColumnDataSource(dict(x=[],y=[]))
    mroll     = ColumnDataSource(dict(x=[],y=[]))
    mheading = ColumnDataSource(dict(x=[],y=[]))
    cheading = ColumnDataSource(dict(x=[],y=[]))

    # AXIS setup
    colors = COLORS[:]

    fig1.y_range.flipped = True
    fig1.yaxis.axis_label = 'm_depth (m)'
    fig1.extra_y_ranges = {'vert_vel': Range1d(start=-50, end=50),
                           'dummy':    Range1d(start=0, end=100)}
    fig1.add_layout(place = 'right',
                    obj = LinearAxis(y_range_name = 'vert_vel',
                                     axis_label   = 'vertical velocity (cm/s)'))
    fig1.add_layout(place = 'left',
                    obj = LinearAxis(y_range_name = 'dummy',
                                     axis_label   = ' '))
    fig1.yaxis[1].visible = False
    fig1.yaxis[1].axis_line_alpha = 0
    fig1.yaxis[1].major_label_text_alpha = 0
    fig1.yaxis[1].major_tick_line_alpha = 0
    fig1.yaxis[1].minor_tick_line_alpha = 0


    fig2.yaxis.axis_label = 'pitch (deg)'
    fig2.y_range.start, fig2.y_range.end = -40,40
    fig2.extra_y_ranges = {'battpos': Range1d(start=-1, end = 1),
                           'bpump':   Range1d(start=-275, end=275)}
    fig2.add_layout(place = 'right',
                    obj = LinearAxis(y_range_name = 'battpos',
                                     axis_label = 'battpos (in)'))
    fig2.add_layout(place = 'left',
                    obj = LinearAxis(y_range_name = 'bpump',
                                     axis_label   = 'bpump (cc)'))
    fig2.yaxis[1].visible = False # necessary for spacing. later gets set to true


    fig3.yaxis.axis_label = 'fin/roll (deg)'
    fig3.y_range.start, fig3.y_range.end = -30, 30
#.........这里部分代码省略.........
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:101,代码来源:plot_overview.py

示例12: g

# Plot constraint function contour g(x,y)=0
contour_g = my_bokeh_utils.Contour(plot, line_color='red', line_width=2, legend='g(x,y) = 0')
# Plot corresponding tangent vector
quiver_isolevel = my_bokeh_utils.Quiver(plot, fix_at_middle=False, line_width=2, color='black')
# Plot corresponding tangent vector
quiver_constraint = my_bokeh_utils.Quiver(plot, fix_at_middle=False, line_width=2, color='red')
# Plot mark at position on constraint function
plot.cross(x='x', y='y', color='red', size=10, line_width=2, source=source_mark)

# object that detects, if a position in the plot is clicked on
interactor = my_bokeh_utils.Interactor(plot)
# adds callback function to interactor, if position in plot is clicked, call on_selection_change
interactor.on_click(on_selection_change)

# text input window for objective function f(x,y) to be optimized
f_input = TextInput(value=lagrange_settings.f_init, title="f(x,y):")
f_input.on_change('value', f_changed)

# dropdown menu for selecting one of the sample functions
sample_fun_input_f = Dropdown(label="choose a sample function f(x,y) or enter one below",
                              menu=lagrange_settings.sample_f_names)
sample_fun_input_f.on_click(sample_fun_input_f_changed)

# text input window for side condition g(x,y)=0
g_input = TextInput(value=lagrange_settings.g_init, title="g(x,y):")
g_input.on_change('value', g_changed)

# dropdown menu for selecting one of the sample functions
sample_fun_input_g = Dropdown(label="choose a sample function g(x,y) or enter one below",
                              menu=lagrange_settings.sample_g_names)
sample_fun_input_g.on_click(sample_fun_input_g_changed)
开发者ID:BenjaminRueth,项目名称:Visualization,代码行数:31,代码来源:lagrange_app.py

示例13: compare


#.........这里部分代码省略.........
        p = figure(plot_width=DIM_COMP_W, plot_height=DIM_COMP_H, tools=TOOLS,
                   title=None, logo=None, toolbar_location="above",
                   x_range=Range1d(minx, maxx), y_range=Range1d(miny, maxy),
                   x_axis_type="log", y_axis_type="log"
                   )
        pb = figure(plot_width=DIM_COMP_SM, plot_height=DIM_COMP_H, tools=TOOLS,
                    y_range=p.y_range, x_axis_type="log", y_axis_type="log")
        pa = figure(plot_width=DIM_COMP_W, plot_height=DIM_COMP_SM, tools=TOOLS,
                    x_range=p.x_range, x_axis_type="log", y_axis_type="log")
        pp = figure(plot_width=DIM_COMP_SM, plot_height=DIM_COMP_SM,
                    tools=TOOLS, outline_line_color=None)

        # SPANS
        p.add_layout(plot_fns.get_span(1, 'height'))
        p.add_layout(plot_fns.get_span(1, 'width'))
        pa.add_layout(plot_fns.get_span(1, 'height'))
        pb.add_layout(plot_fns.get_span(1, 'width'))

        # STYLE
        for ax in [p, pa, pb]:
            ax.grid.visible = False
            ax.outline_line_width = 2
            ax.background_fill_color = 'whitesmoke'
        for ax in [pa, pb]:
            ax.xaxis.visible = False
            ax.yaxis.visible = False

        pa.title.text = xlabel
        pb.title.text = ylabel
        pa.title_location, pa.title.align = 'below', 'center'
        pb.title_location, pb.title.align = 'left', 'center'

        # WIDGETS
        q_input = TextInput(value='', title="P* cutoff",
                            placeholder='e.g. 0.05')
        gene_input = TextInput(value='', title="Gene list",
                               placeholder='e.g. TP53,BRAF')
        radio_include = RadioGroup(labels=["Include", "Exclude"], active=0)
        widgets = widgetbox(q_input, gene_input, radio_include, width=200,
                            css_classes=['widgets_sg'])

        grid = gridplot([[pb, p, widgets],
                         [Spacer(width=DIM_COMP_SM), pa, Spacer()]],
                        sizing_mode='fixed')

        cb_inclusion = CustomJS(args=dict(genes=gene_input), code="""
            var gene_str = genes.value
            if (!gene_str)
                return;
            var include = cb_obj.active == 0 ? true : false
            selectPathwaysByGenes(gene_str, include);
            """)
        cb_genes = CustomJS(args=dict(radio=radio_include), code="""
            var gene_str = cb_obj.value
            if (!gene_str)
                return;
            var include = radio.active == 0 ? true : false
            selectPathwaysByGenes(gene_str, include);
            """)
        radio_include.js_on_change('active', cb_inclusion)
        gene_input.js_on_change('value', cb_genes)

        # SCATTER
        p.circle("e1", "e2", source=source, **SCATTER_KW)
        pa.circle('e1_only', 1, source=source, **SCATTER_KW)
        pb.circle(1, 'e2_only', source=source, **SCATTER_KW)
开发者ID:sggaffney,项目名称:pathscore,代码行数:67,代码来源:routes.py

示例14: plotting

	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")
#.........这里部分代码省略.........
开发者ID:copperwire,项目名称:cephalopod,代码行数:101,代码来源:interactive_plotting.py

示例15: Button

            'lws':[2]
        }
    ))

circobs = p.circle(x='xs', y='ys', color='colors',
    source=ColumnDataSource(data=
        {
            'xs':[[]],
            'ys':[[]],
            'colors':['white'],
        }
    ))

# add a button widget and configure with the call back
button = Button(label="Fetch Data")
namefield = TextInput(value="", title="Name(s):")
bandfield = TextInput(value="", title="Band(s):")

# add a text renderer to out plot (no data yet)

with open('/root/astrocats/astrocats/supernovae/output/names.min.json') as f:
    names = json.loads(f.read())
names = list(names.keys())
unames = [x.upper() for x in names]

bands = plotting.bandcodes
ubands = [x.upper() for x in bands]

nds = []

def callback():
开发者ID:guillochon,项目名称:catexplorer,代码行数:31,代码来源:main.py


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