It would be nice to be able to interactively display and hide lines in a bokeh plot. Say, I have created my plot something like this:
from bokeh.plotting import output_file, figure, show
from numpy.random import normal, uniform
meas_data_1 = normal(0, 1, 100)
meas_data_2 = uniform(-0.5, 0.5, 100)
output_file("myplot.html", title="My plot")
fig = figure(width=500, plot_height=500)
fig.line(x=range(0, len(meas_data_1)), y=meas_data_1)
fig.line(x=range(0, len(meas_data_2)), y=meas_data_2)
show(fig)
How can I add the possibility to interactively enable/disable one of the two lines?
I know that this is on the wish list (see this feature request), but that doesn't sound like it would be implemented too soon.
I have the impression that this should be possible using a CheckBoxGroup and a self-defined callback, but unfortunately this callback has to be written in JavaScript, which I have absolutely no experience in.
See Question&Answers more detail:os