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.
If you are using the Bokeh server you can simply set the location to a new value:
important_time.location = new_value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With