在以下示例中:
from ipywidgets import interact
import numpy as np
from bokeh.models import Slider
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
output_notebook()
x = np.linspace(0, 2*np.pi, 2000)
y = np.sin(x)
p = figure(title="simple line example", plot_height=300, plot_width=600, y_range=(-5,5))
r = p.line(x, y, color="#2222aa", line_width=3)
def update(f, w=1, A=1, phi=0):
f.title='fdsafdsafewa'
if f == "sin": func = np.sin
elif f == "cos": func = np.cos
elif f == "tan": func = np.tan
r.data_source.data['y'] = A * func(w * x + phi)
push_notebook()
show(p, notebook_handle=True)
interact(update, f='Hi there!', w=(1,5), phi=(0, 20, 0.1))
当前,分配给滑块的变量w,a和phi作为标签显示在滑块的左侧。有没有办法删除它们,或者以不涉及在交互部分中编辑其变量名的方式更改标签?
答案 0 :(得分:0)
首先,interact
根本不是Bokeh的一部分,它是ipywidgets
库的一部分。在任何情况下,标签都是从函数参数名称中获取的,因此您只需要随意更改即可,例如
interact(update, Omega=1, Amplitude=1, Phase=0):