你如何 remove/change ipywidgets 交互功能上的小部件标签?

How do you remove/change labels of widgets on ipywidgets Interact feature?

在下面的例子中:

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 作为标签显示在滑块的左侧。有没有办法删除它们,或者以不涉及在交互部分编辑变量名称的方式更改标签?

首先,interact 根本不是 Bokeh 的一部分,它是 ipywidgets 库的一部分。在任何情况下,标签都是从函数参数名称中获取的,因此您只需要根据需要更改它们,例如

interact(update, Omega=1, Amplitude=1, Phase=0):