【问题标题】:Bokeh layout resize multiple plots散景布局调整多个图的大小
【发布时间】:2021-08-07 01:20:55
【问题描述】:

使用来自https://github.com/bokeh/bokeh/blob/branch-2.4/examples/plotting/file/sizing_mode.py的示例

我添加了第二个情节。大小调整模式似乎只适用于第一个情节。 有没有一个技巧可以让两个图都响应调整大小?谢谢

from bokeh.core.enums import SizingMode
from bokeh.layouts import column
from bokeh.models import Select
from bokeh.plotting import figure, output_file, show
from bokeh.sampledata.iris import flowers as df

colormap = {'setosa': 'red', 'versicolor': 'green', 'virginica': 'blue'}
colors = [colormap[x] for x in df.species]

plot = figure(sizing_mode="fixed")
plot.circle(df.petal_length, df.petal_width, color=colors, alpha=0.2, size=10)

plot2 = figure(sizing_mode="fixed")
plot2.circle(df.petal_length, df.petal_width, color=colors, alpha=0.2, size=10)

select = Select(title="Sizing mode", value="fixed", options=list(SizingMode), width=300)
select.js_link('value', plot, 'sizing_mode')

layout = column(select, plot, plot2)
layout.sizing_mode = "stretch_both" # set separately to avoid also setting children

output_file("sizing_mode.html", title="sizing_mode.py example")
show(layout)

【问题讨论】:

    标签: layout bokeh


    【解决方案1】:

    我在该代码中发现了我的错误。应该在布局上完成 js_link 而不仅仅是第一个情节。

    select.js_link('value', layout, 'sizing_mode')
    

    这很好用。谢谢。

    【讨论】:

      猜你喜欢
      • 2015-02-08
      • 1970-01-01
      • 1970-01-01
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      • 2011-08-31
      • 2015-04-30
      • 2022-09-28
      相关资源
      最近更新 更多