如何在python中将标题添加到bokeh仪表板?

问题描述 投票:2回答:2

我在bokeh中创建了一个仪表板,但是如何向其添加通用标头?

enter image description here我之前做了很多研究,但似乎以前没有人问过这个简单的问题。

感谢您的帮助:)

python header bokeh dashboard
2个回答
1
投票

正如Eugene所说,您可以使用div容器设置标题,然后在列输出中设置它。

这里有一些示例代码可能有助于理解:

output_file("slider.html")
title = Div(text='<h1 style="text-align: center">Example Header</h1>')
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)
tab1 = Panel(child=p1, title="circle")

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)
tab2 = Panel(child=p2, title="line")

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

layout = column(title, tabs, sizing_mode='scale_width')

curdoc().add_root(layout)

1
投票

只需将仪表板包裹在column中,其中第一项是带有标题文本的Div

© www.soinside.com 2019 - 2024. All rights reserved.