In [103]:
import bokeh.models
import bokeh.plotting
import IPython.html.widgets
import numpy as np
bokeh.plotting.output_notebook()
In [104]:
x = np.linspace(0, 2*np.pi, 1000)
y1 = np.sin(x)
y2 = np.cos(x)
In [105]:
source1 = bokeh.models.ColumnDataSource(data=dict(x=x, y=y1))
source2 = bokeh.models.ColumnDataSource(data=dict(x=x, y=y2))
p = bokeh.plotting.figure(title="test")
p.line(x, y1, source=source1, color="red")
p.line(x, y2, source=source2)
Out[105]:
In [106]:
def update(A=1, p=0, w=1):
source1.data['y'] = A*np.sin(w * x + p)
source2.data['y'] = A*np.cos(w * x + p)
source1.push_notebook()
source2.push_notebook()
In [107]:
bokeh.plotting.show(p)
In [108]:
IPython.html.widgets.interact(update, A=(1,5), p=(0,10,0.1), w=(0,100))