Finally had a good thought and tried using the multiline vs line. Sort of got something along the lines that I’m looking for, although I’m going to have to spend a lot of time working on making it pretty and presentable.
The sliders take the line width down to .01, so the curve disappears. This is a clunky way to do it to say the least, so any feedback or better ideas much appreciated. Code below (started with the multi-line example and modified):
import numpy as np
from bokeh.document import Document
from bokeh.models import ColumnDataSource, DataRange1d, Plot, LinearAxis, Grid, Slider, CustomJS
from bokeh.models.glyphs import MultiLine
from bokeh.plotting import show, output_file
from bokeh.io import vplot, hplot, vform, gridplot
output_file(“mline.html”)
N = 9
x = np.linspace(-2, 2, N)
y = x**2
xpts = np.array([-.09, -.12, .0, .12, .09])
ypts = np.array([-.1, .02, .1, .02, -.1])
source = ColumnDataSource(dict(
xs=[xpts*(1+i/10.0)+xx for i, xx in enumerate(x)],
ys=[ypts*(1+i/10.0)+yy for i, yy in enumerate(y)],
color=[“red”, “blue”, “green”,“red”, “blue”, “green”,“red”, “blue”, “green”],
lw=[1,2,3,4,5,6,7,8,9]
)
)
xdr = DataRange1d()
ydr = DataRange1d()
callback = CustomJS(args=dict(source=source), code="""
var data = source.get(‘data’);
var f = cb_obj.get(‘value’)
lw = data[‘lw’]
lw[4]=f
// trigger update of data source
source.trigger(‘change’);
“”")
callback2 = CustomJS(args=dict(source=source), code="""
var data = source.get(‘data’);
var f = cb_obj.get(‘value’)
lw = data[‘lw’]
lw[6]=f
// trigger update of data source
source.trigger(‘change’);
“”")
slider = Slider(start=0.01, end=4.01, value=4.01, step=4, title=“Curve 4”, callback=callback)
slider2 = Slider(start=0.01, end=4.01, value=4.01, step=4, title=“Curve 6”, callback=callback2)
plot = Plot(
title=None, x_range=xdr, y_range=ydr, plot_width=800, plot_height=800,
h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None)
glyph = MultiLine(xs=“xs”, ys=“ys”, line_color=“color”, line_width=“lw”)
plot.add_glyph(source, glyph)
xaxis = LinearAxis()
plot.add_layout(xaxis, ‘below’)
yaxis = LinearAxis()
plot.add_layout(yaxis, ‘left’)
plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
layout = vform(slider,slider2)
superlayout=hplot(plot,layout)
show(superlayout)