I am creating a very large Bokeh figure (approx 1200x700) as part of a server and displaying thousands of datapoints using both scatter and lines (to connect the points). The user interaction (zooming, panning) can be slow sometimes depending on the number of datapoints, so I have been experimenting with tuning the level-of-detail (lod) parameters to improve the performance. The problem is that I don’t see a difference between using the default lod parameter values and changing them to their lowest possible values (e.g. 1 for every parameter). Am I doing something wrong in how I am using the lod parameters? Below is a minimum working example with every lod parameter set to 1. When I comment them out, I don’t see any difference in performance of zooming/panning.
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource, HoverTool
import numpy as np
np.random.seed(42)
x = np.random.rand(10000) * 1000
y = np.random.rand(10000) * 1
source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(
width=1260,
height=725,
title="Bokeh LOD Test",
tools="pan,wheel_zoom,box_zoom,reset,save",
lod_threshold = 1,
lod_interval = 1,
lod_timeout = 1,
lod_factor = 1
)
p.line('x', 'y', source=source, line_width=2, color='blue', legend_label='Line')
scatter = p.scatter('x', 'y', source=source, size=5, color='red', legend_label='Points')
hover = HoverTool(renderers=[scatter], tooltips=[("x", "@x"), ("y", "@y")])
p.add_tools(hover)
curdoc().add_root(p)
p.legend.location = "top_left"

