
I’m using an older version of Bokeh (3.11.6). I have a marker on a plot and I would like to update the location of the marker when the user selects a different value.
The update() function seems like the most straightforward way to go, but I’m not quite sure how to use it. Here’s what I’ve tried.
from bokeh.plotting import figure
from bokeh.models import Range1d
import panel as pn
pn.extension()
x = list(range(1,10))
y = list(1 for i in range(1,10))
p = figure(
height=130,
width=1800)
p.line(x=x, y=y)
int_input = pn.widgets.IntInput(name='Select Value', value=5, step=1, start=1, end=9)
star_location= int_input.value
marker= p.star(star_location, 1, size=20, color="navy", alpha=0.5, legend_label="You are here")
def plot_update(event):
r = Range1d
r.star_location= int_input.value
marker.update(star_location)
int_input.param.watch(plot_update, 'value')
pn.Column(int_input, p)
I also tried using renderers.remove(), but I would rather update if possible.
x = list(range(1,10))
y = list(1 for i in range(1,10))
p = figure(
height=130,
width=1800)
p.line(x=x, y=y)
int_input = pn.widgets.IntInput(name='Select Value', value=5, step=1, start=1, end=9)
star_location= int_input.value
marker= p.star(star_location, 1, size=20, color="navy", alpha=0.5, legend_label="You are here")
def plot_update(marker):
p.renderers.remove(marker)
star_location= int_input.value
marker= p.star(star_location, 1, size=20, color="navy", alpha=0.5, legend_label="You are here")
int_input.param.watch(plot_update, 'value')
pn.Column(int_input, p)


