简体   繁体   English

如何在ipywidgets Interact功能上删除/更改小部件的标签?

[英]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.

相关问题 Jupyter 交互 ipywidgets:一个参数的多个小部件 - Jupyter interact ipywidgets: several widgets for one argument 如何从“ipywidgets”更改使用“interact_manual”创建的按钮标签? 以及如何更改该按钮的大小和颜色? - How do I change a button label created with 'interact_manual' from 'ipywidgets'? and how do I change the size and color of that button? 如何在 Python 中的 Jupyter 笔记本中的 ipywidgets 交互功能中拖动 slider 时停止闪烁? - How to stop flickering while dragging the slider in interact feature of ipywidgets in Jupyter notebook in Python? 如何在tkinter中更改标签位置? - How do you change a labels location in tkinter? 如何删除小部件上的虚线“选择”框? - How do you remove the dotted 'select' box on widgets? 如何在ipywidgets Python的选项卡中显示interact() - How to display interact() in tab in ipywidgets Python 如何让 ipywidgets 交互以在 HTML 中工作? - How to get ipywidgets interact to work in HTML? 如何删除数组中的所有 python tkinter 标签 - How do you remove all python tkinter labels in an array 你如何在python的散景图例中更改标签的大小? - How do you change size of labels in the Bokeh legend in python? ipywidgets 交互:设置帧率? - ipywidgets interact: set the framerate?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM