def make_cds(a, b):
df_summ = df.loc[(df['A'] > a) & (df['B'] < b)]
return df_summ
def make_plot(df_summ):
new_src = ColumnDataSource(df_summ)
exp_cmap = LinearColorMapper(palette="Viridis256",
low = min(df_summ["C"]),
high = max(df_summ["C"]))
p = figure(plot_width = 300, plot_height = 300)
p1 = p.circle('D', 'E', source=new_src, line_color=None, size=15,
fill_color={'field':'C', 'transform':exp_cmap})
return p
A_slider = Slider(start = 0.03, end = 0.12,
step = 0.005, value = 0.07,
title = 'A')
B_slider = Slider(start = 560, end = 760, value = 660,
step = 10, title = 'B')
def slider_callback(attr, old, new):
a = A_slider.value
b = B_slider.value
df_summ = df.loc[(df['A'] > a) & (df['B'] < b)]
new_src = ColumnDataSource(df_summ)
source.data = new_src.data
A_slider.on_change('value', slider_callback)
B_slider.on_change('value', slider_callback)
a = 0.07
b = 660
df_summ = make_cds(a, b)
p = make_plot(df_summ)
layout = column(A_slider, B_slider, p)
show(layout)
Hi @scheine please edit your post to use code formatting so that the code is intelligible (either with the </>
icon on the editing toolbar, or triple backtick ``` fences around the code blocks)
I have removed comment lines, now it is good.
Your code is using python callbacks with the bokeh standalone application show()
command. These are incompatible; python callbacks require you to use bokeh server. See Running a bokeh server.
If you don’t want to use a bokeh server, you need to refactor your code to use JavaScript callbacks.