具有不等宽度项目的散景响应行
bokeh responsive row with items of unequal width
我正在尝试在散景 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))
但这会产生一个响应行,其中图形和小部件框的宽度相等。在平板电脑和移动设备上,这会占用大量宝贵的屏幕空间。
The docs on layouts
指定每个项目必须具有相同的大小模式,但不是每个项目都必须具有相同的大小。我找不到任何关于设置每个项目的相对大小的参考。
我试过 sizing_mode
等各种选项,并设置了不同级别的宽度,但我无法产生所需的行为。
从 Bokeh 开始 0.12.3
儿童等尺寸是内置 Bokeh 布局(例如 row
等)的唯一可用选项。但是,您可以将不同的儿童嵌入到您自己的 HTML 模板,使用 bokeh.embed
函数,这会让您更好地控制事物。
例如,如果您调用:
components((s1, widgetbox))
然后你会得到一个元组:
(script, (s1_div, widgetbox_div))
您可以将 <script>
和两个 <div>
模板化为 HTML 模板。这些组件将显示在您插入 <div>
的任何位置。
我正在尝试在散景 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))
但这会产生一个响应行,其中图形和小部件框的宽度相等。在平板电脑和移动设备上,这会占用大量宝贵的屏幕空间。
The docs on layouts 指定每个项目必须具有相同的大小模式,但不是每个项目都必须具有相同的大小。我找不到任何关于设置每个项目的相对大小的参考。
我试过 sizing_mode
等各种选项,并设置了不同级别的宽度,但我无法产生所需的行为。
从 Bokeh 开始 0.12.3
儿童等尺寸是内置 Bokeh 布局(例如 row
等)的唯一可用选项。但是,您可以将不同的儿童嵌入到您自己的 HTML 模板,使用 bokeh.embed
函数,这会让您更好地控制事物。
例如,如果您调用:
components((s1, widgetbox))
然后你会得到一个元组:
(script, (s1_div, widgetbox_div))
您可以将 <script>
和两个 <div>
模板化为 HTML 模板。这些组件将显示在您插入 <div>
的任何位置。