I was just going through the Quickstart guide and run across one of the examples: https://github.com/bokeh/bokeh/blob/master/examples/plotting/notebook/interact_basic.ipynb
I adjusted the script so that it could work as a .py script and produce an HTML file:
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, show, output_notebook, output_file
import numpy as np
x = np.linspace(0, 2*np.pi, 2000)
y = np.sin(x)
output_file(‘Sliders.html’)
source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(title=“simple line example”, plot_height=300, plot_width=600)
p.line(x, y, color="#2222aa", line_width=3, source=source, name=“foo”)
def update(f, w=1, A=1, phi=0):
if f == “sin”: func = np.sin
elif f == “cos”: func = np.cos
elif f == “tan”: func = np.tan
source.data[‘y’] = A * func(w * x + phi)
#source.push_notebook()
from IPython.html.widgets import interact
interact(update, f=[“sin”, “cos”, “tan”], w=(0,100), A=(1,10), phi=(0, 10, 0.1))
show(p)
``
However, this throws an error:
:0: FutureWarning: IPython widgets are experimental and may change in the future
.
Traceback (most recent call last):
File “sinusSliders.py”, line 19, in
interact(update, f=[“sin”, “cos”, “tan”], w=(0,100), A=(1,10), phi=(0, 10, 0
.1))
File "C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\interactio
n.py", line 310, in interact
w = interactive(f, **kwargs)
File "C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\interactio
n.py", line 184, in interactive
container = Box(_dom_classes=[‘widget-interact’])
File "C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\widget_box
.py", line 40, in init
super(Box, self).init(**kwargs)
File “C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\widget.py”
, line 481, in init
super(DOMWidget, self).init(*pargs, **kwargs)
File “C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\widget.py”
, line 156, in init
self.open()
File “C:\Users\adi\Anaconda3\lib\site-packages\IPython\html\widgets\widget.py”
, line 174, in open
self.comm = Comm(**args)
File “C:\Users\adi\Anaconda3\lib\site-packages\IPython\kernel\comm\comm.py”, l
ine 63, in init
self.open(data)
File “C:\Users\adi\Anaconda3\lib\site-packages\IPython\kernel\comm\comm.py”, l
ine 96, in open
raise RuntimeError("Comms cannot be opened without a kernel "
RuntimeError: Comms cannot be opened without a kernel and a comm_manager attache
d to that kernel.
Is there a way to make the script produce a HTML page with sliders?