首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用bokeh.layouts.GridSpec?

如何使用bokeh.layouts.GridSpec?
EN

Stack Overflow用户
提问于 2020-03-05 21:38:11
回答 1查看 223关注 0票数 2

看看https://github.com/Maluuba/bokeh/blob/master/bokeh/layouts.py,我很难弄清楚如何实际显示以下代码的结果:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2020-03-06 04:12:20

我还不能使用bokeh.layouts.GridSpec跨越多个列,但这里有一个解决方案,它使用bokeh.layouts.layout并在创建图形时指定plot_width。我正在使用bokeh-1.4.0

代码语言:javascript
复制
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)

输出如下所示:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60546649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档