gpt4 book ai didi

python - 构建具有复杂布局的 Bokeh 面板的示例?

转载 作者:行者123 更新时间:2023-11-30 22:54:34 25 4
gpt4 key购买 nike

我正在尝试制作具有相对复杂布局的 Bokeh 面板,因此我尝试将当前布局的一半移动到一个 Panel 中,将一半移动到另一个面板中只是为了玩玩,如下所示:

selects = HBox(top_users_select, new_users_select, t1_users_select, t2_users_select, top_recent_users_select)
tab1 = Panel(inputs)
tab2 = Panel(VBox(HBox(plot2, plot1, plot3, plot4), HBox(plot5, plot6, plot7, plot8), data_table))
tabs = tabs(tab1, tab2)
show(tabs)

但是这给了我以下错误:

File "main_panel.py", line 589, in <module>:
tab1 = Panel(inputs) Traceback (most recent call last):
File "/Users/joe/anaconda3/lib/python3.5/site-packages/bokeh/application/handlers/code_runner.py", line 71, in run
exec(self._code, module.__dict__)
File "/Users/joe/Desktop/scripts/src/main/python/Bokeh apps/insights/main_panel.py", line 589, in <module>
tab1 = Panel(inputs)
TypeError: __init__() takes 1 positional argument but 2 were given

我对 Bokeh 相当陌生,查看文档我不知道如何解析此错误并解决它。 有人能给我举一个在 Bokeh 面板中布局相当复杂的网格的示例吗?或者告诉我错误的含义以及如何解决它?

最佳答案

您可以使用在选项卡内创建复杂的布局。您甚至可以将它们混合起来,例如 row(column(button1, button2), button3)

示例:

from bokeh.models.widgets import Panel, Tabs, Toggle, TextInput
from bokeh.io import output_notebook, show
from bokeh.plotting import figure

from bokeh.layouts import column, row

p1 = figure(plot_width=300, plot_height=300)
p1.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)

p2 = figure(plot_width=300, plot_height=300)
p2.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5)

toggle1 = Toggle(label="Foo", button_type="success")
toggle2 = Toggle(label="Foo", button_type="warning")
text_input = TextInput(value="default", title="Label:")

tab1 = Panel(child=row(p1,toggle2), title="circle")
tab2 = Panel(child=column(p2,toggle1, text_input), title="line")

tabs = Tabs(tabs=[ tab1, tab2 ])
output_notebook()
show(tabs)

参见https://docs.bokeh.org/en/latest/docs/user_guide/layout.html了解更多详情

关于python - 构建具有复杂布局的 Bokeh 面板的示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37728598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com