问题描述
使用gridplot(),我可以轻松地在网格上布局不同的图,使用components(),所有图的组合html作为单个变量div_combined返回到我的视图。
我想在我的gridplot html中布局的每个图上方都包含一些描述,但是不知道如何修改视图中的div_combined。我最好不要使用gridplot,而只是单独返回每个图html,然后创建其他网格html吗?
from bokeh.embed import components
from bokeh.plotting import figure
p1,p2,p3,p4 = figure()
grid = gridplot([[p1,p2],[p3,p4]],plot_width=563,plot_height=325)
script_combined,div_combined = components(grid)
msg = 'Dashboard'
return render_template('grid_view_with_desc.html',msg=msg,script_combined=script_combined,div_combined=div_combined)
谢谢!
解决方法
代替使用:
p1,p2,p3,p4 = figure()
尝试一下:
p1 = figure(plot_width=563,plot_height=325,title='P1 title goes here')
p2 = figure(plot_width=563,title='P2 title goes here')
p3 = figure(plot_width=563,title='P3 title goes here')
p4 = figure(plot_width=563,title='P4 title goes here')
应该工作...吗?