我试图在散景0.12.3中创建一个包含图形和窗口小部件框的响应行,其中窗口小部件的宽度比图形小得多。
我只能通过以下方式实现前者:
from bokeh.io import output_file, show
from bokeh.layouts import row, widgetbox
from bokeh.models.widgets import RadioButtonGroup, TextInput
from bokeh.plotting import figure
output_file("layout.html")
x = list(range(11))
y0 = x
y1 = [10 - i for i in x]
y2 = [abs(i - 5) for i in x]
# create a new plot
s1 = figure(width=600, plot_height=600, title=None)
s1.circle(x, y0, size=10, color="navy", alpha=0.5)
widgets = widgetbox([RadioButtonGroup(labels=["a", "b"]), TextInput(title="Input:", width=150)], width=150)
# put the results in a row
show(row([s1, widgets], responsive=True))
但是这会生成响应行,其中图形和窗口小部件的宽度相等。在平板电脑和移动设备上,这可能耗费大量宝贵的屏幕空间。
布局上的文档http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html 指定每个项目必须具有相同的大小调整模式,但不是每个项目必须具有相同的大小。我无法找到关于设置每个项目的相对大小的任何参考。
我已经使用了各种选项,例如sizing_mode
,并设置了不同级别的宽度,但我无法产生所需的行为。
答案 0 :(得分:1)
从Bokeh 0.12.3
起,对于儿童来说,相等大小的内容是内置Bokeh布局的唯一可用选项,例如row
等。但是,您可以将不同的孩子嵌入到您自己的HTML模板,使用result in sql server :函数,可以更好地控制事物。
例如,如果你打电话:
components((s1, widgetbox))
然后你会得到一个元组:
(script, (s1_div, widgetbox_div))
您可以将<script>
和两个<div>
模板化为HTML模板。只要您插入<div>
s。