1 回答
![?](http://img1.sycdn.imooc.com/5458657e000125a302200220-100-100.jpg)
TA贡献1831条经验 获得超9个赞
你已经给自己答案了。使用components是实现它的一种方式。请查看Bokeh 嵌入文档以了解所有选项。
如果您想要一个可以使用此方法的单个文件实现(使用 Bokeh 1.1.0 测试):
from jinja2 import Template
from bokeh.plotting import figure
from bokeh.embed import file_html
from bokeh.models import Div, Paragraph, Row, Column
from bokeh.resources import CDN
from bokeh.util.browser import view
template = Template("""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ title if title else "Bokeh Plot" }}</title>
{{ bokeh_css | safe }}
{{ bokeh_js | safe }}
</head>
<body>
{{ plot_div | safe }}
{{ plot_script | safe }}
</body>
</html> """)
p1 = figure(plot_width = 400, plot_height = 400)
p2 = figure(plot_width = 400, plot_height = 400)
p3 = figure(plot_width = 800, plot_height = 400)
p1.circle([1, 2, 3], [4, 5, 6])
p2.line([1, 2, 3], [4, 5, 6])
p3.line([1, 2, 3], [4, 5, 6])
html = file_html(Column(Row(p1, p2), Row(p3)), template = template, resources = CDN)
output_file = 'css_classes.html'
with open(output_file, 'w') as f:
f.write(html)
view(output_file)
结果:
添加回答
举报