on_change ( 'value', update_data ) # Set up layouts and add to document inputs = column ( text, offset, amplitude, phase, freq ) bokeh_app = pn. data = dict ( x = x, y = y ) for w in : w. on_change ( 'value', update_title ) def update_data ( attrname, old, new ): # Get the current slider values a = amplitude. pi ) freq = Slider ( title = "frequency", value = 1.0, start = 0.1, end = 5.1, step = 0.1 ) # Set up callbacks def update_title ( attrname, old, new ): 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, step = 0.1 ) phase = Slider ( title = "phase", value = 0.0, start = 0.0, end = 2 * np. sin ( x ) source = ColumnDataSource ( data = dict ( x = x, y = y )) # Set up plot plot = figure ( height = 400, width = 400, title = "my sine wave", tools = "crosshair,pan,reset,save,wheel_zoom", x_range =, y_range = ) plot. Bokeh ( p, theme = "dark_minimal" ) bokeh_paneįrom bokeh.layouts import column, row from bokeh.models import ColumnDataSource, Slider, TextInput # Set up data N = 200 x = np. wedge ( x = 0, y = 1, radius = 0.4, start_angle = cumsum ( 'angle', include_zero = True ), end_angle = cumsum ( 'angle' ), line_color = "white", fill_color = 'color', legend_field = 'country', source = data ) p. sum () * 2 * pi data = Category20c p = figure ( height = 350, title = "Pie Chart", toolbar_location = None, tools = "hover", tooltips =, x_range = ( - 0.5, 1.0 )) r = p. These types of callbacks require a Bokeh server to be running such that the Python code can be executed. Supported platforms Bokeh is officially supported (and continuously tested) on CPython versions 3.9 and later. There are three things required for a Bokeh plot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |