[英]How do you remove/change labels of widgets on ipywidgets Interact feature?
In the following example: 在以下示例中:
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))
The graph produced is as follows: 生成的图形如下:
Currently, the variables w, a and phi assigned to the sliders show up to the left of the slider as labels. 当前,分配给滑块的变量w,a和phi作为标签显示在滑块的左侧。 Is there a way to remove them, or change the labels in a manner which doesn't involve editing their variable names in the interact section?
有没有办法删除它们,或以不涉及在交互部分中编辑其变量名的方式更改标签?
First off, interact
is not part of Bokeh at all, it is part of the ipywidgets
library. 首先,
interact
根本不是Bokeh的一部分,它是ipywidgets
库的一部分。 In any case the labels are taken from the function parameter names, so you only need to change them however you like, eg 在任何情况下,标签都是从函数参数名称中获取的,因此您只需要随意更改即可,例如
interact(update, Omega=1, Amplitude=1, Phase=0):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.