How to use the bokeh.io.curdoc function in bokeh

To help you get started, we’ve selected a few bokeh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Transversal_strain_test / main.py View on Github external
Block.add_baby([3.25,4.25,3.25,2.25],[-1,0,1,0],diagram,"#333333")
Block.add_circular_baby(1,0,1.5,1.5,diagram,"#333333")
## add horizontal force arrows
Block.add_force_arrows(4.75,[1.4,0.5,-0.5,-1.4],2,'xE',diagram)
Block.add_force_arrows(-4.75,[1.4,0.5,-0.5,-1.4],-2,'xE',diagram)
## add vertical force arrows
Block.add_force_arrows([3,1,-1,-3],2.25,2,'yE',diagram)
Block.add_force_arrows([3,1,-1,-3],-2.25,-2,'yE',diagram)
## add force labels (must be done in same order as arrows and after arrows)
Block.add_force_label(8,0,'x',diagram)
Block.add_force_label(-8,0,'x',diagram)
Block.add_force_label(0,5.5,'y',diagram)
Block.add_force_label(0,-5.5,'y',diagram)

## Send to window
curdoc().add_root(row(column(ForceX_input,ForceY_input,E_input,Nu_input),diagram))
curdoc().title = split(dirname(__file__))[-1].replace('_',' ').replace('-',' ')  # get path of parent directory and only use the name of the Parent Directory for the tab name. Replace underscores '_' and minuses '-' with blanks ' '
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Instant_centre_of_rotation / main.py View on Github external
current_coords.data=dict(x=[l*math.sin(w)],y=[l*math.cos(w)])
    ICR_label_glyph.text_alpha=1
    ICR_label_source.data=dict(x=[0.1+l*math.sin(w)],y=[0.1+l*math.cos(w)],ICR=['ICR'])
    Vb_label_source.data=dict(x=[0],y=[l*math.cos(w)-0.77],Vb=['V'])
    Va_label_source.data=dict(x=[0.50+l*math.sin(w)],y=[0],Va=['V'])
    i=int(new*40/math.pi)
    spurkurve.data = dict(x=DataPlotter[0:DataPlotterDictionary[i],0],y=DataPlotter[0:DataPlotterDictionary[i],1])
Wmega_input.on_change('value',slide)

# add app description
description_filename = join(dirname(__file__), "description.html")

description = Div(text=open(description_filename).read(), render_as_text=False, width=1200)


curdoc().add_root(column(description,row(p),Wmega_input))
curdoc().title = split(dirname(__file__))[-1].replace('_',' ').replace('-',' ')  # get path of parent directory and only use the name of the Parent Directory for the tab name. Replace underscores '_' and minuses '-' with blanks ' '
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Fourier_Transform / main.py View on Github external
elif func_select.value == "1":
            mod_arrow_source_Re3.stream(dict(x1=[0],y1=[0],x2=[0],y2=[2*pi]),rollover=1)
        elif func_select.value == "sin(t)":
            mod_arrow_source_Im.stream(dict(x1=[-1],y1=[0],x2=[-1],y2=[pi]),rollover=1)
            mod_arrow_source_Im2.stream(dict(x1=[1],y1=[0],x2=[1],y2=[-pi]),rollover=1)
            mod_arrow_line_source2.data = dict(x=[1,1],y=[0,-pi])
        elif func_select.value == "cos(t)":
            mod_arrow_source_Re.stream(dict(x1=[-1],y1=[0],x2=[-1],y2=[2*pi]),rollover=1)
            mod_arrow_source_Re2.stream(dict(x1=[1],y1=[0],x2=[1],y2=[2*pi]),rollover=1)
    update_mod_functions(x_Im,y_mod, y_mod_Im, y_FT_Re_mod, y_FT_Im_mod)

## set initial modification to "Shifting"
changeMod(0,0,"Shifting")
               
## Send to window
curdoc().add_root(layout)  

## get path of parent directory and only use the name of the Parent Directory for the tab name. Replace underscores '_' and minuses '-' with blanks ' '
curdoc().title = split(dirname(__file__))[-1].replace('_',' ').replace('-',' ')
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Wave_Propagation / main.py View on Github external
def pause():
  [active] = global_active.data['active']
  [callback_id] = global_callback_id.data['callback_id']
  play_pause_button.label = 'Play'
  try:
    curdoc().remove_periodic_callback(callback_id)
    global_active.data = dict(active=[False])
  except ValueError:
    print('WARNING: callback_id was already removed - this can happen if stop was pressed after pause, usually no serious problem; if stop was not called this part should be changed')
  except:
    print('This error is not covered: ', sys.exc_info()[0])
    raise
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Stopping_distances / SD_Problem.py View on Github external
self.t+=t_update
        # add point to graphs
        self.Plotter.addPointInTime(self.t)
        # calculate new displacement and velocity
        s = 0.5*self.a*self.t**2+self.v*self.t
        v = self.a*self.t+self.v
        # if the car has stopped or started to reverse then stop the simulation
        if (v<=0):
            # place the car with 0 velocity
            self.Vis.move(s,0)
            curdoc().remove_periodic_callback(self.callback_id)
        # if the car has hit the wall then stop the simulation
        elif (s>=30):
            # place the car at the wall
            self.Vis.move(30,v)
            curdoc().remove_periodic_callback(self.callback_id)
        else:
            # place the car
            self.Vis.move(s,v)
github jhu-lcsr / costar_plan / costar_hyper / hyperopt_plot.py View on Github external
key_dimensions = [('name', 'Model'), ('error_distribution_limits', 'Error Distribution')]
key_dimension_display_strs = [vt[1] for vt in key_dimensions]

table = hv.Table(rdf, key_dimensions, 'accuracy_range_value')
print('1.0 table created')
table_bars = table.to.bars(key_dimension_display_strs, 'accuracy_range_value', ['train_val_test'])
table_bars = table_bars.options(stack_index=1, width=1920, height=1080, xrotation=90, tools=['hover'])
print('2.0 table bars')
table_plot = renderer.get_plot(table_bars)
print('3.0 table plot')
plot_list = [[table_plot.state]]
print('3.0 plot list')
# layout_child = layout(plot_list, sizing_mode='fixed')
layout_child = layout(plot_list)
curdoc().clear()
curdoc().add_root(layout_child)
github bokeh / bokeh / bokeh / embed.py View on Github external
def _ModelInDocument(models, apply_theme=None):
    doc = _find_existing_docs(models)
    old_theme = doc.theme

    if apply_theme is FromCurdoc:
        from .io import curdoc; curdoc
        doc.theme = curdoc().theme
    elif apply_theme is not None:
        doc.theme = apply_theme

    models_to_dedoc = _add_doc_to_models(doc, models)

    if settings.perform_document_validation():
        doc.validate()

    yield doc

    for model in models_to_dedoc:
        doc.remove_root(model, apply_theme)
    doc.theme = old_theme
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Stopping_distances / SD_Problem.py View on Github external
def Reset(self):
        # reset time and distance
        self.t = 0
        self.s = 0
        
        # move the car to the start with current velocity
        self.Vis.move(self.s, self.v)

        # reset graphs
        self.Plotter.Reset()

        # enable start button again if all callbacks are removed
        if not curdoc().session_callbacks:
            self.startSim.disabled = False
        else: # otherwise stop the running simulation
            curdoc().remove_periodic_callback(self.callback_id)
            self.startSim.disabled = False
github bokeh / bokeh / examples / reference / models / radio_button_group_server.py View on Github external
def radiogroup_click(attr,old,new):
    active_radio=radio_button_group.active ##Getting radio button value

    # filter the dataframe with value in radio-button
    if active_radio==0:
        selected_df = df[df['label'] == 'Red']
    elif active_radio==1:
        selected_df = df[df['label'] == "Orange"]

    source.data=dict(x=selected_df.x, y=selected_df.y,label=selected_df.label)

radio_button_group.on_change('active',radiogroup_click)

layout=row(radio_button_group, plot_figure)

curdoc().add_root(layout)
curdoc().title = "Radio Button Group Bokeh Server"