散景图无法拉伸以填充剩余空间

时间:2019-08-05 12:10:29

标签: python bokeh

我正在尝试扩展“散景”标签内的中间情节。 中间图形构造为:

p = figure(tools=['xpan', 'reset', 'save','xwheel_zoom'],x_axis_type='datetime', plot_height=650, plot_width=950,
            toolbar_location='left', title= "Monthly cashflows roll out")

l = layout([
        [column([inputs, pie]), p, column(cardsVarColumn,cardsStatColumn)]
    ])

我尝试添加sizing_mode='stretch_both' 但是中间的情节仍然没有尽力而为,以填补图中所示的剩余空间:

enter image description here

1 个答案:

答案 0 :(得分:1)

您应该将sizing_mode Stretch_both添加到您想拉伸以填充剩余空间的图的列中。

from bokeh.plotting import figure, show
from bokeh.models.widgets import Select, RangeSlider, PreText
from bokeh.layouts import column, row

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

p2 = figure(plot_width=400, plot_height=400)
p2.square([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="olive", alpha=0.5)

select1 = Select(title="Select Variable:", value="Linear equal principal", options=["Linear equal principal", "foo", "bar"])
select2 = Select(title="Currency:", value="EUR", options=["EUR", "USD"])
range_slider = RangeSlider(start=0, end=10, value=(1,9), step=.1, title="Date Range")

pre1 = PreText(text="Total interests CF in a date range", width=300, height=50)
pre2 = PreText(text="Outstanding Principal", width=300, height=50)
pre3 = PreText(text="Number of Loans", width=300, height=50)

show(row(column(select1, select2, range_slider, p1), column(children=[p2], sizing_mode='stretch_both'), column(pre1, pre2, pre3)))

enter image description here