私はBokehで初心者です。curdoc()
をHTMLファイルに保存することが可能かどうかを知りたいのですが?それはボケサーバーによってをを実行しなければならない、これはそれを保存することができない、機能するためにはボケアプリケーションあるBokehでcurdocを保存する
import numpy as np from bokeh.palettes
import RdYlGn11 as palette from bokeh.plotting
import figure from bokeh.layouts
import row, widgetbox from bokeh.models
import ColumnDataSource from bokeh.models.widgets
import Slider, TextInput, Select from bokeh.io
import curdoc, output_file, save, set_curdoc
x = np.array([-10., -8., -7., -2., 0., 1., 2., 5., 7., 9.])
y = np.array([-15., -12., -9., -5., 1., 4., 6., 7., 9., 12.])
def f(x, y, a, b):
return a * x + b * y
z = f(x, y, -2, 3.2)
colors = np.array(palette)
task_color = np.arange(-10, 10, 10)
source = ColumnDataSource(data = dict(X = x, Y = y, Z = z, color = colors[task_color.searchsorted(z)]))
plot = figure(plot_height = 800, plot_width = 800)
plot.circle("X", "Y", size = 10, line_color = "color", fill_color = "color", source = source)
plot.text("X", "Y", text = "Z", source = source)
A = Slider(title = "First coefficient", value = -2., start = -10, end = 10, step = 1.)
B = Slider(title = "Second coefficient", value = 3.2, start = 0., end = 5., step = 0.1)
def update_data(attrname, ols, new):
a = A.value
b = B.value
x = np.array([-10., -8., -7., -2., 0., 1., 2., 5., 7., 9.])
y = np.array([-15., -12., -9., -5., 1., 4., 6., 7., 9., 12.])
z = f(x, y, a, b)
source.data = dict(X = x, Y = y, Z = z, color = colors[task_color.searchsorted(z)])
for w in [A, B]:
w.on_change('value', update_data)
inputs = widgetbox(A, B)
curdoc().add_root(row(inputs, plot))
curdoc().title = "My test"