I am trying to use the slider widget to get user-provided value to set the size of the circle. I am using bokeh server to do this. But i am running into issues with setting up the columndatasource.
Another related question is there a way to create circle glyphs of different size using the same statement?
This is the code I have thus far for working with the slider:
···
from bokeh.plotting import Figure
from bokeh.models import HBox, ColumnDataSource
from bokeh.models.widgets import Slider
from bokeh.io import curdoc
cir_x=[2]
cir_y=[10]
cir_size=5
cir_source = ColumnDataSource(data=dict(
x=cir_x,
y=cir_y,
sz=cir_size
))
plot = Figure(plot_width=400, plot_height=400, title=‘Changing the size of circle’,
x_range=[0,20], y_range=[0,20])
plot.circle(‘x’, ‘y’, size=‘sz’, source=cir_source)
sz_slide = Slider(start=0, end=20, step=1, value=5, title=“Circle Size”)
def update_radius(attrname, old, new):
a = sz_slide.value
x=[2]
y=[10]
cir_source.data = dict(x=x,y=y,sz=a)
for w in [sz_slide]:
w.on_change(‘value’, update_radius)
h_layout = HBox(children=[plot,sz_slide])
curdoc().add_root(h_layout)