栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用MultiSelect小部件隐藏和显示bokeh中的线

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用MultiSelect小部件隐藏和显示bokeh中的线

此PR中刚刚在版本0.12.1中添加了对执行此操作的支持(使用MultiSelect小部件隐藏/显示行):https
:
//github.com/bokeh/bokeh/pull/4868

这里有一个示例(在下面复制):https
:
//github.com/bokeh/bokeh/blob/master/examples/plotting/file/line_on_off.py

""" Example demonstrating turning lines on and off - with JS only"""import numpy as npfrom bokeh.io import output_file, showfrom bokeh.layouts import rowfrom bokeh.palettes import Viridis3from bokeh.plotting import figurefrom bokeh.models import CheckboxGroup, CustomJSoutput_file("line_on_off.html", title="line_on_off.py example")pre = """    if (0 in checkbox.active) {        l0.visible = true    } else {        l0.visible = false    }    if (1 in checkbox.active) {        l1.visible = true    } else {        l1.visible = false    }    if (2 in checkbox.active) {        l2.visible = true    } else {        l2.visible = false    }"""p = figure()props = dict(line_width=4, line_alpha=0.7)x = np.linspace(0, 4 * np.pi, 100)l0 = p.line(x, np.sin(x), color=Viridis3[0], legend="Line 0", **props)l1 = p.line(x, 4 * np.cos(x), color=Viridis3[1], legend="Line 1", **props)l2 = p.line(x, np.tan(x), color=Viridis3[2], legend="Line 2", **props)callback = CustomJS(pre=pre, args={})checkbox = CheckboxGroup(labels=["Line 0", "Line 1", "Line 2"], active=[0, 1, 2], callback=callback, width=100)callback.args = dict(l0=l0, l1=l1, l2=l2, checkbox=checkbox)layout = row(checkbox, p)show(layout)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/596642.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号