看看https://github.com/Maluuba/bokeh/blob/master/bokeh/layouts.py,我很难弄清楚如何实际显示以下代码的结果:
from bokeh.layouts import GridSpec
from bokeh.plotting import figure, show
fig1 = figure() #... plotting..
fig2 = figure() #... plotting..
fig3 = figure() #... plotting..
fig4 = figure() #... plotting..
fig5 = figure() #... plotting..
gspec = GridSpec(2, 3)
gspec[0, 0:2] = fig1
gspec[0, 2] = fig2
gspec[1, 0] = fig3
gspec[1, 1] = fig4
gspec[1, 2] = fig5
show(gspec) # where to use sizing_mode='stretch_both' ??我的目标是在第1行的2列跨度上绘制fig1,并使图2-5具有相同的大小。所有图形都需要根据窗口大小动态改变大小。有谁有主意吗?
我使用的是bokeh 1.4
发布于 2020-03-06 04:12:20
我还不能使用bokeh.layouts.GridSpec跨越多个列,但这里有一个解决方案,它使用bokeh.layouts.layout并在创建图形时指定plot_width。我正在使用bokeh-1.4.0
import bokeh
import bokeh.plotting
fig1 = bokeh.plotting.figure(plot_width=400, plot_height=200)
fig1.line([0,1],[0,1])
fig2 = bokeh.plotting.figure(plot_width=200, plot_height=200)
fig2.line([0,1],[1,0])
fig3 = bokeh.plotting.figure(plot_width=200, plot_height=200)
fig3.line([0,1,2],[1,0,1])
fig4 = bokeh.plotting.figure(plot_width=200, plot_height=200)
fig4.line([0,1,2],[0,1,0])
fig5 = bokeh.plotting.figure(plot_width=200, plot_height=200)
fig5.line([0,1,2],[0,0,1])
layout = bokeh.layouts.layout([
[fig1,fig2],
[fig3,fig4,fig5]
])
bokeh.io.show(layout)输出如下所示:

https://stackoverflow.com/questions/60546649
复制相似问题