具有不等宽项目的散景响应行 [英] bokeh responsive row with items of unequal width

查看:33
本文介绍了具有不等宽项目的散景响应行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在bokeh 0.12.3中创建一个响应行,其中包含一个图形和一个小部件框,其中该小部件框的宽度比图形小得多.

I'm trying to create a responsive row in bokeh 0.12.3 that contains a figure and a widgetbox, where the widgetbox has a much smaller width than the figure.

我只能通过以下方法实现前者:

I'm able to achieve only the former with the following:

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))

但是这会产生一个响应行,其中图形和小部件的宽度相等.在平板电脑和移动设备上,这可能会占用大量宝贵的屏幕空间.

But this produces a responsive row where the width of the figure and widgetbox are equal. On tablets and mobile devices this can use up a lot of precious screen real-estate.

关于版式的文档指定每个项目必须具有相同的大小调整模式,但不必指定每个项目都必须具有相同的大小.我找不到设置每个项目的相对尺寸的参考.

The docs on layouts specify that every item must have the same sizing mode, but not that every item must have the same size. I can't find any reference on setting relative sizes of each item.

我尝试过各种选择,例如 sizing_mode ,并在各种级别上设置宽度,但是我无法产生所需的行为.

I've played around with various options like sizing_mode, and setting widths at various levels, but I can't produce the desired behaviour.

推荐答案

从散景版本开始, 0.12.3 对于子集的等号尺寸是内置散景布局(例如<代码>行等.但是,您可以使用

As of Bokeh 0.12.3 equal-sizes for children is the only available option for the built-in Bokeh layouts such as row, etc. However, you could possibly embed the different children into your own HTML template, using the bokeh.embed functions, which would give you finer control over things.

例如,如果您致电:

components((s1, widgetbox))

然后您将返回一个元组:

Then you will get back a tuple:

(script, (s1_div, widgetbox_div)) 

您可以将< script> 和两个< div> 模板化为HTML模板.只要您插入< div> s,这些组件就会显示出来.

You can template the <script> and the two <div>s into an HTML template. The components will show up wherever you insert the <div>s.

这篇关于具有不等宽项目的散景响应行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆