Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bokeh: Dynamically update the location of a vertical line.

I have added a vertical line to an existing bokeh figure using the following lines, following the example bokeh docs:

from bokeh.models import Span
important_time = Span(location=shift_no, dimension='height', line_color='red', line_dash='dashed', line_width=3)
my_figure.add_layout(important_time)

I update the source data of the figure dynamically based on selections made in some widgets. And the vertical line should change for each new data. The problems that the above code keeps adding new vertical lines to existing ones, which is no surprise.

Anybody knows a method to remove previous vertical lines or just update its location? I run it on bokeh server in case that makes any difference in the solution.

like image 705
CrossEntropy Avatar asked Sep 18 '25 14:09

CrossEntropy


1 Answers

If you are using the Bokeh server you can simply set the location to a new value:

important_time.location = new_value
like image 78
bigreddot Avatar answered Sep 20 '25 05:09

bigreddot